List of usage examples for java.util SortedSet size
int size();
From source file:de.shadowhunt.sonar.plugins.ignorecode.model.IssuePatternTest.java
@Test public void testParseLineRangeAllLines() throws Exception { final IssuePattern pattern = IssuePattern.parseLine("resourcePattern;rulePattern;*"); Assert.assertEquals("resourcePattern name must match", "resourcePattern", pattern.getResourcePattern()); Assert.assertEquals("rulePattern name must match", "rulePattern", pattern.getRulePattern()); final SortedSet<Integer> full = pattern.getLines(); Assert.assertNotNull("SortedSet must not be null", full); Assert.assertEquals("SortedSet must contain the exact number of entries", 0, full.size()); }
From source file:de.shadowhunt.sonar.plugins.ignorecode.model.IssuePatternTest.java
@Test public void testParseLineSingle() throws Exception { final IssuePattern pattern = IssuePattern.parseLine("resourcePattern;rulePattern;[2]"); Assert.assertEquals("resourcePattern name must match", "resourcePattern", pattern.getResourcePattern()); Assert.assertEquals("rulePattern name must match", "rulePattern", pattern.getRulePattern()); final SortedSet<Integer> full = pattern.getLines(); Assert.assertNotNull("SortedSet must not be null", full); Assert.assertEquals("SortedSet must contain the exact number of entries", 1, full.size()); Assert.assertTrue("SortedSet must contain line 2", full.contains(2)); }
From source file:org.eclipse.skalli.view.internal.filter.AbstractSearchFilter.java
/** * Returns a map with the subprojects of the given search hits. * Key: UUID.toString() of a project in searchHits; Value: list of SearchHits of subprojects of that project. *//*from w w w .j a v a 2 s .c o m*/ protected Map<String, List<SearchHit<Project>>> getSubprojects(List<SearchHit<Project>> searchHits) { SearchService searchService = getSearchService(); Map<String, List<SearchHit<Project>>> subrojects = new HashMap<String, List<SearchHit<Project>>>(); for (SearchHit<Project> searchHit : searchHits) { Project project = searchHit.getEntity(); UUID uuid = project.getUuid(); SortedSet<Project> subprojects = project.getSubProjects(); if (subprojects.size() > 0) { subrojects.put(uuid.toString(), searchService.asSearchHits(subprojects)); } } return subrojects; }
From source file:de.shadowhunt.sonar.plugins.ignorecode.model.IssuePatternTest.java
@Test public void testParseLineMixed() throws Exception { final IssuePattern pattern = IssuePattern.parseLine("resourcePattern;rulePattern;[2,4-6]"); Assert.assertEquals("resourcePattern name must match", "resourcePattern", pattern.getResourcePattern()); Assert.assertEquals("rulePattern name must match", "rulePattern", pattern.getRulePattern()); final SortedSet<Integer> full = pattern.getLines(); Assert.assertNotNull("SortedSet must not be null", full); Assert.assertEquals("SortedSet must contain the exact number of entries", 4, full.size()); Assert.assertTrue("SortedSet must contain line 2", full.contains(2)); Assert.assertTrue("SortedSet must contain line 4", full.contains(4)); Assert.assertTrue("SortedSet must contain line 5", full.contains(5)); Assert.assertTrue("SortedSet must contain line 6", full.contains(6)); }
From source file:org.cloudata.core.commitlog.pipe.BufferPool.java
int clearExpiredEntries(int msec) { PoolEntry e = new PoolEntry((System.currentTimeMillis() + 10) - msec); int sizeOfDeallocated = 0; synchronized (bufferMap) { Iterator<TreeSet<PoolEntry>> iter = bufferMap.values().iterator(); while (iter.hasNext()) { TreeSet<PoolEntry> entrySet = iter.next(); SortedSet<PoolEntry> expiredSet = entrySet.headSet(e); if (expiredSet.isEmpty() == false) { LOG.debug(expiredSet.size() + " pool entries are removed"); Iterator<PoolEntry> expiredIter = expiredSet.iterator(); while (expiredIter.hasNext()) { PoolEntry expiredEntry = expiredIter.next(); poolMonitor.deallocated(expiredEntry.buffer.capacity()); sizeOfDeallocated += expiredEntry.buffer.capacity(); }//from w w w . jav a 2 s.c o m expiredSet.clear(); if (entrySet.isEmpty()) { LOG.debug("entry set is removed"); iter.remove(); } } } } return sizeOfDeallocated; }
From source file:de.shadowhunt.sonar.plugins.ignorecode.model.IssuePatternTest.java
@Test public void testAddLine() throws Exception { final SortedSet<Integer> lines = new TreeSet<>(); lines.add(1);//from ww w . j a v a 2 s. c o m lines.add(3); lines.add(5); final IssuePattern pattern = new IssuePattern("resourcePattern", "rulePattern", lines); final SortedSet<Integer> full = pattern.getLines(); Assert.assertNotNull("SortedSet must not be null", full); Assert.assertEquals("SortedSet must contain the exact number of entries", 3, full.size()); Assert.assertTrue("SortedSet must contain line 1", full.contains(1)); Assert.assertTrue("SortedSet must contain line 3", full.contains(3)); Assert.assertTrue("SortedSet must contain line 5", full.contains(5)); }
From source file:de.shadowhunt.sonar.plugins.ignorecode.model.IssuePatternTest.java
@Test public void testAddLines() throws Exception { final SortedSet<Integer> lines = new TreeSet<>(); IssuePattern.addLines(lines, 2, 2);/* w ww. j a v a2 s. c o m*/ IssuePattern.addLines(lines, 4, 6); final IssuePattern pattern = new IssuePattern("resourcePattern", "rulePattern", lines); final SortedSet<Integer> full = pattern.getLines(); Assert.assertNotNull("SortedSet must not be null", full); Assert.assertEquals("SortedSet must contain the exact number of entries", 4, full.size()); Assert.assertTrue("SortedSet must contain line 2", full.contains(2)); Assert.assertTrue("SortedSet must contain line 4", full.contains(4)); Assert.assertTrue("SortedSet must contain line 5", full.contains(5)); Assert.assertTrue("SortedSet must contain line 6", full.contains(6)); }
From source file:de.shadowhunt.sonar.plugins.ignorecode.model.IssuePatternTest.java
@Test public void testParseLineRange() throws Exception { final IssuePattern pattern = IssuePattern.parseLine("resourcePattern;rulePattern;[2-6]"); Assert.assertEquals("resourcePattern name must match", "resourcePattern", pattern.getResourcePattern()); Assert.assertEquals("rulePattern name must match", "rulePattern", pattern.getRulePattern()); final SortedSet<Integer> full = pattern.getLines(); Assert.assertNotNull("SortedSet must not be null", full); Assert.assertEquals("SortedSet must contain the exact number of entries", 5, full.size()); Assert.assertTrue("SortedSet must contain line 2", full.contains(2)); Assert.assertTrue("SortedSet must contain line 3", full.contains(3)); Assert.assertTrue("SortedSet must contain line 4", full.contains(4)); Assert.assertTrue("SortedSet must contain line 5", full.contains(5)); Assert.assertTrue("SortedSet must contain line 6", full.contains(6)); }
From source file:org.easyrec.plugin.arm.ARMGenerator.java
@Override protected void doExecute(ExecutionControl control, ARMStatistics stats) throws Exception { control.updateProgress(1, 1, "Calculating # of baskets."); ARMConfiguration configuration = getConfiguration(); ARMConfigurationInt intConfiguration; Date start = MySQL.sanitzeForMysql56(new Date()); stats.setStartDate(start);// w w w . ja v a 2s. c o m try { intConfiguration = assocRuleMiningService.mapTypesToConfiguration(configuration, start); logger.info("TenantId:" + intConfiguration.getTenantId()); stats.setCutoffDate(intConfiguration.getCutoffDate()); } catch (Exception e) { stats.setException(e.getMessage()); intConfiguration = null; } if (intConfiguration != null) { tupleCounter.init(); if (control.isAbortRequested()) throw new Exception("ARM was manually aborted!"); control.updateProgress(1, 6, "Calculating # of baskets."); Integer nrBaskets = assocRuleMiningService.getNumberOfBaskets(intConfiguration); stats.setNrBaskets(nrBaskets); if (control.isAbortRequested()) throw new Exception("ARM was manually aborted!"); control.updateProgress(2, 6, "Calculating # of products."); Integer nrProducts = assocRuleMiningService.getNumberOfProducts(intConfiguration); stats.setNrProducts(nrProducts); Integer support = (int) (nrBaskets * (configuration.getSupportPrcnt() / 100)); intConfiguration.setSupport(Math.max(support, configuration.getSupportMinAbs())); if (control.isAbortRequested()) throw new Exception("ARM was manually aborted!"); // TObjectIntHashMap<ItemVO<Integer, Integer>> L1 = assocRuleMiningService.defineL1(intConfiguration); int offset = configuration.getL1KeepItemCount(); int iter = 0; while (offset < configuration.getMaxSizeL1()) { iter++; tupleCounter.init(); control.updateProgress(3, 6, "Defining set L1(" + iter + ")."); TObjectIntHashMap<ItemVO<Integer, Integer>> L1 = assocRuleMiningService.defineL1(intConfiguration, 0, configuration.getL1KeepItemCount()); L1.putAll(assocRuleMiningService.defineL1(intConfiguration, offset, configuration.getItemBatchSize())); stats.setSizeL1(stats.getSizeL1() + L1.size()); stats.setLastSupport(intConfiguration.getSupport()); if (control.isAbortRequested()) throw new Exception("ARM was manually aborted!"); control.updateProgress(4, 6, "Defining set L2(" + iter + ")."); List<TupleVO> L2 = assocRuleMiningService.defineL2(L1, tupleCounter, intConfiguration, stats); stats.setSizeL2(stats.getSizeL2() + L2.size()); if (control.isAbortRequested()) throw new Exception("ARM was manually aborted!"); control.updateProgress(5, 6, "Generating rules(" + iter + ")."); if (configuration.getMaxRulesPerItem() == null) { List<ItemAssocVO<Integer, Integer>> rules = assocRuleMiningService.createRules(L2, L1, intConfiguration, stats, configuration.getConfidencePrcnt()); stats.setSizeRules(rules.size()); for (ItemAssocVO<Integer, Integer> itemAssocVO : rules) { // try { // ruleminingItemAssocDAO.insertItemAssoc(itemAssocVO); // } catch (DataIntegrityViolationException e) { // ruleminingItemAssocDAO.updateItemAssocUsingUniqueKey(itemAssocVO); // } ruleminingItemAssocDAO.insertOrUpdateItemAssoc(itemAssocVO); } } else { int count = 0; Collection<SortedSet<ItemAssocVO<Integer, Integer>>> rules = assocRuleMiningService .createBestRules(L2, L1, intConfiguration, stats, configuration.getConfidencePrcnt()); for (SortedSet<ItemAssocVO<Integer, Integer>> sortedSet : rules) { count += sortedSet.size(); for (ItemAssocVO<Integer, Integer> itemAssocVO : sortedSet) { // try { // ruleminingItemAssocDAO.insertItemAssoc(itemAssocVO); // } catch (DataIntegrityViolationException e) { // ruleminingItemAssocDAO.updateItemAssocUsingUniqueKey(itemAssocVO); // } ruleminingItemAssocDAO.insertOrUpdateItemAssoc(itemAssocVO); } } stats.setNumberOfRulesCreated(stats.getSizeRules() + count); stats.setSizeRules(stats.getSizeRules() + count); } stats.setLastConf(configuration.getConfidencePrcnt()); stats.setNumberOfActionsConsidered( assocRuleMiningService.getNumberOfActions(intConfiguration, null)); offset += configuration.getItemBatchSize(); // there were less items than MaxSizeL1 if (L1.size() < configuration.getItemBatchSize()) { break; } L1.clear(); L2.clear(); } stats.setIterations(iter); // remove old Rules assocRuleMiningService.removeOldRules(intConfiguration, stats); control.updateProgress(6, 6, "Finished"); } // TODO: else write logoutput stats.setEndDate(MySQL.sanitzeForMysql56(new Date())); stats.setDuration((stats.getEndDate().getTime() - stats.getStartDate().getTime()) / 1000); }
From source file:org.eclipse.skalli.commons.StatisticsTest.java
private void assertMixedStatistics(Statistics stats) { SortedSet<UsageInfo> usageInfo = stats.getUsageInfo(); assertEquals(3, usageInfo.size()); SortedSet<UserInfo> userInfo = stats.getUserInfo(); assertEquals(2, userInfo.size());//from w ww .j a va 2 s. com assertEquals(0, userInfo.first().getSequenceNumber()); assertEquals(5, userInfo.last().getSequenceNumber()); SortedSet<BrowserInfo> browserInfo = stats.getBrowserInfo(); assertEquals(1, browserInfo.size()); assertEquals(6, browserInfo.first().getSequenceNumber()); SortedSet<SearchInfo> searchInfo = stats.getSearchInfo(); assertEquals(2, searchInfo.size()); assertEquals(2, searchInfo.first().getSequenceNumber()); assertEquals(8, searchInfo.last().getSequenceNumber()); SortedSet<RefererInfo> referInfo = stats.getRefererInfo(); assertEquals(1, referInfo.size()); assertEquals(3, referInfo.first().getSequenceNumber()); SortedSet<ResponseTimeInfo> responseInfo = stats.getResponseTimeInfo(); assertEquals(1, responseInfo.size()); assertEquals(7, responseInfo.first().getSequenceNumber()); assertEquals(userInfo.first().getTimestamp(), stats.getStartDate()); assertEquals(usageInfo.last().getTimestamp(), stats.getEndDate()); assertEquals(usageInfo.last().getSequenceNumber() + 1, stats.getSequenceNumber()); }