/** * Sort history list by start time in descending order. * @param historyList history list * @return sorted list of BackupCompleteData */ public static ArrayList<BackupInfo> sortHistoryListDesc(ArrayList<BackupInfo> historyList) { ArrayList<BackupInfo> list = new ArrayList<>(); TreeMap<String, BackupInfo> map = new TreeMap<>(); for (BackupInfo h : historyList) { map.put(Long.toString(h.getStartTs()), h); } Iterator<String> i = map.descendingKeySet().iterator(); while (i.hasNext()) { list.add(map.get(i.next())); } return list; }
private void remove( NavigableMap<Interval, TimelineEntry> timeline, Interval interval, boolean incompleteOk ) { timeline.remove(interval); for (Map.Entry<Interval, TreeMap<VersionType, TimelineEntry>> versionEntry : allTimelineEntries.entrySet()) { if (versionEntry.getKey().overlap(interval) != null) { if (incompleteOk) { add(timeline, versionEntry.getKey(), versionEntry.getValue().lastEntry().getValue()); } else { for (VersionType ver : versionEntry.getValue().descendingKeySet()) { TimelineEntry timelineEntry = versionEntry.getValue().get(ver); if (timelineEntry.getPartitionHolder().isComplete()) { add(timeline, versionEntry.getKey(), timelineEntry); break; } } } } } }
Set<FileSet<CopyEntity>> partitionsToDelete = Sets.newHashSet(); for (FileSet<CopyEntity> existingFileSet : this.workUnitsMap.descendingKeySet()) { if (this.comparator.compare(existingFileSet, fileSet) <= 0) { return false;
public void resetLogLevels() { TreeMap<String, LogLevel> latestLogLevelMap = latestLogConfig.get(); LOG.debug("Resetting log levels: Latest log config is {}", latestLogLevelMap); LoggerContext loggerContext = (LoggerContext) LogManager.getContext(false); for (String loggerName : latestLogLevelMap.descendingKeySet()) { LogLevel loggerSetting = latestLogLevelMap.get(loggerName); long timeout = loggerSetting.get_reset_log_level_timeout_epoch(); String resetLogLevel = loggerSetting.get_reset_log_level(); if (timeout < Time.currentTimeMillis()) { LOG.info("{}: Resetting level to {}", loggerName, resetLogLevel); setLoggerLevel(loggerContext, loggerName, resetLogLevel); latestLogConfig.getAndUpdate(input -> { TreeMap<String, LogLevel> result = new TreeMap<>(input); result.remove(loggerName); return result; }); } } loggerContext.updateLoggers(); }
for (Integer key: overlapRangeMap.descendingKeySet()) { List<R> chunk = overlapRangeMap.get(key); int chunkSize = chunk.size();
list.add(exactTerm); for (Long p: a.descendingKeySet()) { list.add(a.get(p)); if (i >= list.size()) {
for (String loggerName : latestConf.descendingKeySet()) { if (!newLogConfigs.containsKey(loggerName)) {
static List<Long> getTopFriends(TreeMap<Long, List<Long>> sortedMap, int N) { // now select the top N users to recommend as potential friends List<Long> recommendations = new ArrayList<Long>(); for (long mutualFriends : sortedMap.descendingKeySet()) { List<Long> potentialFriends = sortedMap.get(mutualFriends); Collections.sort(potentialFriends); for (long potentialFriend : potentialFriends) { recommendations.add(potentialFriend); if (recommendations.size() == N) { return recommendations; } } } // here we have less than N friends recommendations return recommendations; } }
static List<Long> getTopFriends(TreeMap<Long, List<Long>> sortedMap, int N) { // now select the top N users to recommend as potential friends List<Long> recommendations = new ArrayList<Long>(); for (long mutualFriends : sortedMap.descendingKeySet()) { List<Long> potentialFriends = sortedMap.get(mutualFriends); Collections.sort(potentialFriends); for (long potentialFriend : potentialFriends) { recommendations.add(potentialFriend); if (recommendations.size() == N) { return recommendations; } } } // here we have less than N friends recommendations return recommendations; } }
public NavigableSet<Long> getDescendingKeySet() { return map.descendingKeySet(); }
@Override public Iterator<S> iterator() { return hypotheses.descendingKeySet().iterator(); }
@Override public IPOSToken getPreviousElement(Long offset) { NavigableSet<Long> tst = this.sentenceSintax.descendingKeySet(); Iterator<Long> it = this.sentenceSintax.keySet().iterator(); return null; }
public Version getLatestStable() { //TODO: Buffer the latest stable version in some way if (this.store == null || this.store.isEmpty()) { return null; } //Trying to find the latest version marked as stable NavigableSet<Version> descSet = this.store.descendingKeySet(); for (Version v : descSet) { if (v.stable) { return v; } } //If none is found, just return the latest one return this.store.lastKey(); }
public Version getLatestStable() { //TODO: Buffer the latest stable version in some way if (this.store == null || this.store.isEmpty()) { return null; } //Trying to find the latest version marked as stable NavigableSet<Version> descSet = this.store.descendingKeySet(); for (Version v : descSet) { if (v.stable) { return v; } } //If none is found, just return the latest one return this.store.lastKey(); }
/** * Ctor. * * @param window - sorted map with events * @param reverse for reverse iterator */ public AggregationStateSortedIterator(TreeMap<Object, Object> window, boolean reverse) { super(reverse ? window.descendingKeySet().iterator() : window.keySet().iterator()); this.window = window; init(); }
@Override public void cleanup(Context context) throws IOException, InterruptedException { for (int reputation : repToRecordMap.descendingKeySet()) { Pair<Writable, Writable> pair = repToRecordMap.get(reputation); context.write(new IntWritable(reputation), new TextArrayWritable(pair)); } } }
public IPOSToken getNextElement(Long offset) { if(this.sentenceSintax.containsKey(offset)) { NavigableSet<Long> tst = this.sentenceSintax.descendingKeySet(); Iterator<Long> it = this.sentenceSintax.keySet().iterator(); while(it.hasNext()) { Long offsetSintaxPosition = it.next(); if(offsetSintaxPosition>=offset) { IPOSToken triple = this.sentenceSintax.get(offsetSintaxPosition); return triple; } } } return null; }
private String orderedRegex(List<String> regextokens) { String newregex = ""; if (inputstring != null) { String[] inputparts = inputstring.split(" "); TreeMap<Integer,String> regexparts = new TreeMap<Integer,String>(); for (String s : regextokens) { for (int i = 0; i < inputparts.length; i++) { if (inputparts[i].matches(s+"(/\\w+)?")) { regexparts.put(i,s); break; } } } for (int n : regexparts.descendingKeySet()) { newregex = regexparts.get(n) + " " + newregex; } } else for (String s : regextokens) newregex += s + " "; return newregex.trim(); }
/** * returns set of items within confidence bound * @param confidenceLimitPercent * @return */ public List<String> getConfidenceBounds(int confidenceLimitPercent) { List<String> confBoundSet = new ArrayList<String>(); int confidenceLimit = (sampleCount * confidenceLimitPercent) / 100; //sort by count TreeMap<Integer, String> countSortedHistogram = new TreeMap<Integer, String>(); for(Map.Entry<String,Integer> entry : binMap.entrySet()) { countSortedHistogram.put(entry.getValue(), entry.getKey()); } //collect high count items double confCount = 0; for(Integer count : countSortedHistogram.descendingKeySet()) { confCount += count; if (confCount < confidenceLimit) { confBoundSet.add(countSortedHistogram.get(count)); } } return confBoundSet; }
private void remove( NavigableMap<Interval, TimelineEntry> timeline, Interval interval, boolean incompleteOk ) { timeline.remove(interval); for (Map.Entry<Interval, TreeMap<VersionType, TimelineEntry>> versionEntry : allTimelineEntries.entrySet()) { if (versionEntry.getKey().overlap(interval) != null) { if (incompleteOk) { add(timeline, versionEntry.getKey(), versionEntry.getValue().lastEntry().getValue()); } else { for (VersionType ver : versionEntry.getValue().descendingKeySet()) { TimelineEntry timelineEntry = versionEntry.getValue().get(ver); if (timelineEntry.getPartitionHolder().isComplete()) { add(timeline, versionEntry.getKey(), timelineEntry); break; } } } } } }