List of usage examples for java.util SortedSet size
int size();
From source file:org.apache.ctakes.ytex.kernel.KernelUtilImpl.java
private Map<Long, Integer> createInstanceIdToIndexMap(SortedSet<Long> instanceIDs) { Map<Long, Integer> instanceIdToIndexMap = new HashMap<Long, Integer>(instanceIDs.size()); int i = 0;/*from w ww. j ava 2 s.com*/ for (Long instanceId : instanceIDs) { instanceIdToIndexMap.put(instanceId, i); i++; } return instanceIdToIndexMap; }
From source file:org.mulima.internal.freedb.FreeDbJdbcDaoImpl.java
/** * Adds the tracks for the disc id./*from ww w . ja v a 2s .c o m*/ * @param discId the disc's id * @param tracks the tracks to add */ private void addTracks(int discId, SortedSet<Track> tracks) { logger.trace("Entering addTracks"); final String sql = "INSERT INTO `tracks` VALUES(null, :disc_id, :num, :title)"; MapSqlParameterSource[] trackParms = new MapSqlParameterSource[tracks.size()]; int i = 0; for (Track track : tracks) { trackParms[i] = new MapSqlParameterSource(); trackParms[i].addValue("disc_id", discId); trackParms[i].addValue("num", track.getNum()); trackParms[i].addValue("title", track.getFlat(GenericTag.TITLE)); i++; } this.getNamedParameterJdbcTemplate().batchUpdate(sql, trackParms); logger.trace("Exiting addTracks"); }
From source file:org.apache.hadoop.yarn.util.Log4jWarningErrorMetricsAppender.java
private List<Map<String, Element>> getElementsAndCounts(Map<String, SortedMap<Long, Integer>> map, List<Long> cutoffs, SortedSet<PurgeElement> purgeInformation) { if (purgeInformation.size() > maxUniqueMessages) { ErrorAndWarningsCleanup cleanup = new ErrorAndWarningsCleanup(); long cutoff = Time.now() - (messageAgeLimitSeconds * 1000); cutoff = (cutoff / 1000);//from ww w .ja v a 2s .com cleanup.cleanupMessages(map, purgeInformation, cutoff, maxUniqueMessages); } List<Map<String, Element>> ret = new ArrayList<>(cutoffs.size()); for (int i = 0; i < cutoffs.size(); ++i) { ret.add(new HashMap<String, Element>()); } synchronized (lock) { for (Map.Entry<String, SortedMap<Long, Integer>> element : map.entrySet()) { for (int i = 0; i < cutoffs.size(); ++i) { Map<String, Element> retMap = ret.get(i); SortedMap<Long, Integer> qualifyingTimes = element.getValue().tailMap(cutoffs.get(i)); long count = 0; for (Map.Entry<Long, Integer> entry : qualifyingTimes.entrySet()) { count += entry.getValue(); } if (!qualifyingTimes.isEmpty()) { retMap.put(element.getKey(), new Element(count, qualifyingTimes.lastKey())); } } } } return ret; }
From source file:org.apache.hadoop.hbase.regionserver.DefaultMobStoreFlusher.java
@Override public List<Path> flushSnapshot(SortedSet<KeyValue> snapshot, long cacheFlushId, TimeRangeTracker snapshotTimeRangeTracker, AtomicLong flushedSize, MonitoredTask status) throws IOException { ArrayList<Path> result = new ArrayList<Path>(); if (snapshot.size() == 0) return result; // don't flush if there are no entries // Use a store scanner to find which rows to flush. long smallestReadPoint = store.getSmallestReadPoint(); InternalScanner scanner = createScanner(snapshot, smallestReadPoint); if (scanner == null) { return result; // NULL scanner returned from coprocessor hooks means skip normal processing }//w ww . j a v a2 s.c o m StoreFile.Writer writer; long flushed = 0; try { // TODO: We can fail in the below block before we complete adding this flush to // list of store files. Add cleanup of anything put on filesystem if we fail. synchronized (flushLock) { status.setStatus("Flushing " + store + ": creating writer"); // Write the map out to the disk writer = store.createWriterInTmp(snapshot.size(), store.getFamily().getCompression(), false, true, true); writer.setTimeRangeTracker(snapshotTimeRangeTracker); try { if (!isMob) { // It's not a mob store, flush the cells in a normal way flushed = performFlush(scanner, writer, smallestReadPoint); } else { // It's a mob store, flush the cells in a mob way. This is the difference of flushing // between a normal and a mob store. flushed = performMobFlush(snapshot, snapshotTimeRangeTracker, cacheFlushId, scanner, writer, status, smallestReadPoint); } } finally { finalizeWriter(writer, cacheFlushId, status); } } } finally { flushedSize.set(flushed); scanner.close(); } LOG.info("Flushed, sequenceid=" + cacheFlushId + ", memsize=" + StringUtils.humanReadableInt(flushed) + ", hasBloomFilter=" + writer.hasGeneralBloom() + ", into tmp file " + writer.getPath()); result.add(writer.getPath()); return result; }
From source file:net.lmxm.ute.gui.editors.tasks.SubversionExportTaskEditorPanel.java
/** * Gets the revision date text field.//from www . ja va 2 s . c o m * * @return the revision date text field */ private JXDatePicker getRevisionDateTextField() { if (revisionDateTextField == null) { revisionDateTextField = new JXDatePicker(new Date()); revisionDateTextField.setFormats("yyyy-MM-dd"); final JXMonthView monthView = revisionDateTextField.getMonthView(); monthView.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent actionEvent) { if (getUserObject() instanceof SubversionExportTask) { final SubversionExportTask subversionExportTask = (SubversionExportTask) getUserObject(); final SortedSet<Date> selection = monthView.getSelection(); subversionExportTask.setRevisionDate(selection.size() == 0 ? null : selection.first()); } } }); } return revisionDateTextField; }
From source file:org.eclipse.winery.repository.rest.resources._support.AbstractComponentsResource.java
/** * Returns resources for all known component instances * <p>// w ww.j av a2 s.co m * Required by XaaSPackager logic * <p> * TODO: remove that method and refactor callers */ public Collection<AbstractComponentInstanceResource> getAll() { Class<? extends DefinitionsChildId> idClass = RestUtils .getComponentIdClassForComponentContainer(this.getClass()); SortedSet<? extends DefinitionsChildId> allDefinitionsChildIds = RepositoryFactory.getRepository() .getAllDefinitionsChildIds(idClass); ArrayList<AbstractComponentInstanceResource> res = new ArrayList<>(allDefinitionsChildIds.size()); for (DefinitionsChildId id : allDefinitionsChildIds) { AbstractComponentInstanceResource r = AbstractComponentsResource.getComponentInstanceResource(id); res.add(r); } return res; }
From source file:uk.co.danielrendall.imagetiler.strategies.CircleStrategy.java
public void doAfterInitialise() { Point center = new Point(((double) xMin) + ((double) width / 2.0d), ((double) yMin) + ((double) height / 2.0d)); SortedSet<Pixel> pixels = new TreeSet<Pixel>(getRadiusComparator(center)); GridStrategy strategy = new GridStrategy(); strategy.initialise(this); while (strategy.hasNext()) { Pixel next = strategy.next();//from w w w. j a va2s .c om if (filter.shouldInclude(next)) pixels.add(next); } log.info("Max pixels " + width * height + " pixels, I have " + pixels.size()); pixelIterator = pixels.iterator(); }
From source file:org.eclipse.winery.repository.rest.resources.AbstractComponentsResource.java
/** * Returns resources for all known component instances * * Required by topologytemplateedit.jsp/* w ww . j av a 2 s .c o m*/ */ public Collection<AbstractComponentInstanceResource> getAll() { Class<? extends TOSCAComponentId> idClass = RestUtils .getComponentIdClassForComponentContainer(this.getClass()); SortedSet<? extends TOSCAComponentId> allTOSCAcomponentIds = RepositoryFactory.getRepository() .getAllTOSCAComponentIds(idClass); ArrayList<AbstractComponentInstanceResource> res = new ArrayList<>(allTOSCAcomponentIds.size()); for (TOSCAComponentId id : allTOSCAcomponentIds) { AbstractComponentInstanceResource r = AbstractComponentsResource.getComponentInstaceResource(id); res.add(r); } return res; }
From source file:org.jasig.ssp.service.impl.PersonServiceBulkCoachLookupIntegrationTest.java
@Test public void testGetAllCurrentCoachesFiltersDuplicates() throws ObjectNotFoundException { final Person jamesDoe = person(JAMES_DOE); final Person advisor0 = person(ADVISOR_0); jamesDoe.setCoach(advisor0);/*from w w w. j av a 2s .c o m*/ personService.save(jamesDoe); sessionFactory.getCurrentSession().flush(); final SortedSet<Person> result = personService.getAllCurrentCoaches(null); assertEquals(2, result.size()); }
From source file:org.jasig.ssp.service.impl.PersonServiceBulkCoachLookupIntegrationTest.java
@Test public void testGetAllCurrentCoachesFiltersDuplicatesByIdNotName() throws ObjectNotFoundException { final String duplicatePersonSchoolId = ADVISOR_0.schoolId() + "_foo"; this.createExternalPerson(duplicatePersonSchoolId, ADVISOR_0.username() + "_foo", ADVISOR_0.firstName(), // everything else the same ADVISOR_0.lastName(), ADVISOR_0.middleName(), ADVISOR_0.primaryEmailAddress()); // this should create the person record Person duplicatePerson = personService.getBySchoolId(duplicatePersonSchoolId, true); assertNotNull(duplicatePerson); // sanity check final Person jamesDoe = person(JAMES_DOE); jamesDoe.setCoach(duplicatePerson);/*from w w w . j a va 2s. c om*/ personService.save(jamesDoe); sessionFactory.getCurrentSession().flush(); final SortedSet<Person> result = personService.getAllCurrentCoaches(null); assertEquals(3, result.size()); }