List of usage examples for java.util NavigableSet last
E last();
From source file:org.alfresco.extension.bulkimport.source.fs.DirectoryAnalyser.java
private Pair<List<FilesystemBulkImportItem>, List<FilesystemBulkImportItem>> constructImportItems( final String sourceRelativeParentDirectory, final Map<String, SortedMap<BigDecimal, Pair<File, File>>> categorisedFiles) throws InterruptedException { Pair<List<FilesystemBulkImportItem>, List<FilesystemBulkImportItem>> result = null; if (categorisedFiles != null) { final List<FilesystemBulkImportItem> directoryItems = new ArrayList<>(); final List<FilesystemBulkImportItem> fileItems = new ArrayList<>(); result = new Pair<>(directoryItems, fileItems); for (final String parentName : categorisedFiles.keySet()) { if (importStatus.isStopping() || Thread.currentThread().isInterrupted()) throw new InterruptedException( Thread.currentThread().getName() + " was interrupted. Terminating early."); final SortedMap<BigDecimal, Pair<File, File>> itemVersions = categorisedFiles.get(parentName); final NavigableSet<FilesystemBulkImportItemVersion> versions = constructImportItemVersions( itemVersions);// w w w . j a v a2 s .c om final boolean isDirectory = versions.last().isDirectory(); final FilesystemBulkImportItem item = new FilesystemBulkImportItem(parentName, isDirectory, sourceRelativeParentDirectory, versions); if (isDirectory) { directoryItems.add(item); } else { fileItems.add(item); } } } return (result); }
From source file:org.apache.hadoop.hbase.regionserver.Memcache.java
private void getRowKeyBefore(ConcurrentSkipListSet<KeyValue> set, KeyValue search, NavigableSet<KeyValue> candidates, final NavigableSet<KeyValue> deletes, final long now) { NavigableSet<KeyValue> headSet = set.headSet(search); // If we tried to create a headMap and got an empty map, then there are // no keys at or before the search key, so we're done. if (headSet.isEmpty()) { return;//from w ww. j av a 2s. com } // If there aren't any candidate keys at this point, we need to search // backwards until we find at least one candidate or run out of headMap. if (candidates.isEmpty()) { KeyValue lastFound = null; for (Iterator<KeyValue> i = headSet.descendingIterator(); i.hasNext();) { KeyValue found = i.next(); // if the last row we found a candidate key for is different than // the row of the current candidate, we can stop looking -- if its // not a delete record. boolean deleted = found.isDeleteType(); if (lastFound != null && this.comparator.matchingRows(lastFound, found) && !deleted) { break; } // If this isn't a delete, record it as a candidate key. Also // take note of this candidate so that we'll know when // we cross the row boundary into the previous row. if (!deleted) { if (Store.notExpiredAndNotInDeletes(this.ttl, found, now, deletes)) { lastFound = found; candidates.add(found); } else { // Its expired. Store.expiredOrDeleted(set, found); } } else { // We are encountering items in reverse. We may have just added // an item to candidates that this later item deletes. Check. If we // found something in candidates, remove it from the set. if (Store.handleDeletes(found, candidates, deletes)) { remove(set, found); } } } } else { // If there are already some candidate keys, we only need to consider // the very last row's worth of keys in the headMap, because any // smaller acceptable candidate keys would have caused us to start // our search earlier in the list, and we wouldn't be searching here. SortedSet<KeyValue> rowTailMap = headSet.tailSet(headSet.last().cloneRow(HConstants.LATEST_TIMESTAMP)); Iterator<KeyValue> i = rowTailMap.iterator(); do { KeyValue found = i.next(); if (found.isDeleteType()) { Store.handleDeletes(found, candidates, deletes); } else { if (ttl == HConstants.FOREVER || now < found.getTimestamp() + ttl || !deletes.contains(found)) { candidates.add(found); } else { Store.expiredOrDeleted(set, found); } } } while (i.hasNext()); } }
From source file:org.opennms.web.rest.AlarmRestServiceTest.java
private OnmsAlarm getLastAlarm() { final NavigableSet<OnmsAlarm> alarms = new TreeSet<OnmsAlarm>(new Comparator<OnmsAlarm>() { @Override/* ww w. j a v a 2 s . c o m*/ public int compare(final OnmsAlarm a, final OnmsAlarm b) { return a.getId().compareTo(b.getId()); } }); alarms.addAll(getAlarmDao().findAll()); return alarms.last(); }