private static <K, V> V mappedValue(TreeMap<K, V> map, K key) { Entry<K, V> e = map.floorEntry(key); if (e != null && e.getValue() == null) { e = map.lowerEntry(key); } return e == null ? null : e.getValue(); }
@Implementation protected void restat(String path) { Map.Entry<String, Stats> mapEntry = stats.floorEntry(path); for (;;) { // We will hit all matching paths, longest one first. We may hit non-matching paths before we // find the right one. if (mapEntry == null) { stat = DEFAULT_STATS; return; } String key = mapEntry.getKey(); if (path.startsWith(key)) { stat = mapEntry.getValue(); return; } mapEntry = stats.lowerEntry(key); } }
@Override public void emitBatch(TransactionAttempt tx, Object coordinatorMeta, BatchOutputCollector collector) { Map<Integer, Object> metas = new HashMap<>(); _cachedMetas.put(tx.getTransactionId(), metas); int partitions = _emitter.numPartitions(); Entry<BigInteger, Map<Integer, Object>> entry = _cachedMetas.lowerEntry(tx.getTransactionId()); Map<Integer, Object> prevCached; if (entry != null) { prevCached = entry.getValue(); } else { prevCached = new HashMap<>(); } for (int i = _index; i < partitions; i += _numTasks) { RotatingTransactionalState state = _partitionStates.get(i); if (state == null) { state = new RotatingTransactionalState(_state, "" + i); _partitionStates.put(i, state); } state.removeState(tx.getTransactionId()); Object lastMeta = prevCached.get(i); if (lastMeta == null) lastMeta = state.getLastState(); Object meta = _emitter.emitPartitionBatch(tx, collector, i, lastMeta); metas.put(i, meta); } }
_cachedMetas.put(tx.getTransactionId(), metas); Entry<Long, Map<String, Object>> entry = _cachedMetas.lowerEntry(tx.getTransactionId()); Map<String, Object> prevCached; if(entry!=null) {
_cachedMetas.put(tx.getTransactionId(), metas); Entry<Long, Map<String, Object>> entry = _cachedMetas.lowerEntry(tx.getTransactionId()); Map<String, Object> prevCached; if (entry != null) {
@Override protected Map.Entry nextEntry(Key key) { return tuples.lowerEntry(key); } }
public MediaMetadataCompat getStationBefore(String stationId) { Map.Entry<String, MediaMetadataCompat> entry = mStationListById.lowerEntry(stationId); if (entry != null) { return entry.getValue(); } return null; }
private void addBefore(LinkedList<Long> timeList, LinkedList<DATA> dataList, long time, int nbefore) { Entry<Long, DATA> floorEntry = null; int seen = 0; long currentTime = time; while ((floorEntry = this.timeSeries.lowerEntry(currentTime)) != null) { currentTime = floorEntry.getKey(); if (seen < nbefore) { dataList.addFirst(floorEntry.getValue()); timeList.addFirst(currentTime); seen++; } else { break; } }// The entry was either null (didn't exist) or was beyond the threshold return; }
private void addBefore(LinkedList<Long> timeList,LinkedList<DATA> dataList, long time, long threshbefore) { Entry<Long, DATA> floorEntry = null; long minTime = time - threshbefore; long currentTime = time; while ((floorEntry = this.timeSeries.lowerEntry(currentTime)) != null) { currentTime = floorEntry.getKey(); if (currentTime >= minTime) { dataList.addFirst(floorEntry.getValue()); timeList.addFirst(currentTime); } else { break; } }// The entry was either null (didn't exist) or was beyond the threshold return; }
@Override public T getPrior(ITimeInstant time) { Entry<ITimeInstant, WrappedObject> entry = collection.lowerEntry(time); if (entry == null) { return null; } if (entry.getValue().timePeriod.contains(time)) { entry = collection.lowerEntry(entry.getKey()); } if (entry == null) { return null; } return entry.getValue().item; }
public float getPepFDR(float score) { float fdr; if (isGreaterBetter) fdr = pepLevelFDRMap.lowerEntry(score).getValue(); else fdr = pepLevelFDRMap.higherEntry(score).getValue(); return fdr; }
@Override public Bin<T> lower(double p) { return binFromEntry(_bins.lowerEntry(p)); }
public float getPSMQValue(float score) { float fdr; if (isGreaterBetter) fdr = psmLevelFDRMap.lowerEntry(score).getValue(); else fdr = psmLevelFDRMap.higherEntry(score).getValue(); return fdr; }
private boolean isSameAsPrevious(Long key, Resource capacity) { Entry<Long, Resource> previous = cumulativeCapacity.lowerEntry(key); return (previous != null && previous.getValue().equals(capacity)); }
private boolean isSameAsPrevious(Long key, Resource capacity) { Entry<Long, Resource> previous = cumulativeCapacity.lowerEntry(key); return (previous != null && previous.getValue().equals(capacity)); }
private WrappedObject getWrappedObjectAtTime(ITimeInstant time) { Entry<ITimeInstant, WrappedObject> latestPriorEntry = collection.lowerEntry(time); if (latestPriorEntry == null) { // no intervals exist which start before the query time. return null; } WrappedObject latestPrior = latestPriorEntry.getValue(); if (!latestPrior.timePeriod.contains(time)) { // the latest-starting interval prior to the query time expires before the query time, // so there is no matching interval for this query time. return null; } // the interval contains the time, so return the enclosed value. return latestPrior; }
/** * @param chainId * @return The last {@link ResidueNumber} of the specified chain (the one farthest down in the PDB file) */ public ResidueNumber getLast(String chainId) { Map.Entry<ResidueNumber,Integer> entry = treeMap.lastEntry(); while (true) { if (entry.getKey().getChainName().equals(chainId)) return entry.getKey(); entry = treeMap.lowerEntry(entry.getKey()); if (entry == null) return null; } }
@Implementation protected void restat(String path) { Map.Entry<String, Stats> mapEntry = stats.floorEntry(path); for (;;) { // We will hit all matching paths, longest one first. We may hit non-matching paths before we // find the right one. if (mapEntry == null) { stat = DEFAULT_STATS; return; } String key = mapEntry.getKey(); if (path.startsWith(key)) { stat = mapEntry.getValue(); return; } mapEntry = stats.lowerEntry(key); } }
@Override public void emitBatch(TransactionAttempt tx, Object coordinatorMeta, BatchOutputCollector collector) { Map<Integer, Object> metas = new HashMap<Integer, Object>(); _cachedMetas.put(tx.getTransactionId(), metas); int partitions = _emitter.numPartitions(); Entry<BigInteger, Map<Integer, Object>> entry = _cachedMetas.lowerEntry(tx.getTransactionId()); Map<Integer, Object> prevCached; if(entry!=null) { prevCached = entry.getValue(); } else { prevCached = new HashMap<Integer, Object>(); } for(int i=_index; i < partitions; i+=_numTasks) { RotatingTransactionalState state = _partitionStates.get(i); if(state==null) { state = new RotatingTransactionalState(_state, "" + i); _partitionStates.put(i, state); } state.removeState(tx.getTransactionId()); Object lastMeta = prevCached.get(i); if(lastMeta==null) lastMeta = state.getLastState(); Object meta = _emitter.emitPartitionBatch(tx, collector, i, lastMeta); metas.put(i, meta); } }
@Override public void emitBatch(TransactionAttempt tx, Object coordinatorMeta, BatchOutputCollector collector) { Map<Integer, Object> metas = new HashMap<>(); _cachedMetas.put(tx.getTransactionId(), metas); int partitions = _emitter.numPartitions(); Entry<BigInteger, Map<Integer, Object>> entry = _cachedMetas.lowerEntry(tx.getTransactionId()); Map<Integer, Object> prevCached; if(entry!=null) { prevCached = entry.getValue(); } else { prevCached = new HashMap<>(); } for(int i=_index; i < partitions; i+=_numTasks) { RotatingTransactionalState state = _partitionStates.get(i); if(state==null) { state = new RotatingTransactionalState(_state, "" + i); _partitionStates.put(i, state); } state.removeState(tx.getTransactionId()); Object lastMeta = prevCached.get(i); if(lastMeta==null) lastMeta = state.getLastState(); Object meta = _emitter.emitPartitionBatch(tx, collector, i, lastMeta); metas.put(i, meta); } }