本文整理了Java中java.util.TreeMap.floorEntry()
方法的一些代码示例,展示了TreeMap.floorEntry()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeMap.floorEntry()
方法的具体详情如下:
包路径:java.util.TreeMap
类名称:TreeMap
方法名:floorEntry
暂无
代码示例来源:origin: apache/usergrid
/**
* Get the shard entry that should hold this value
*/
public ShardEntryGroup getShardId( final Long seek ) {
Map.Entry<Long, ShardEntryGroup> entry = shards.floorEntry( seek );
if ( entry == null ) {
throw new NullPointerException( "Entry should never be null, this is a bug" );
}
return entry.getValue();
}
}
代码示例来源:origin: apache/hbase
/**
* lookup the node containing the specified procId.
* @param node cached node to check before doing a lookup
* @param procId the procId to lookup
* @return the node that may contains the procId or null
*/
private BitSetNode lookupClosestNode(final BitSetNode node, final long procId) {
if (node != null && node.contains(procId)) return node;
final Map.Entry<Long, BitSetNode> entry = map.floorEntry(procId);
return entry != null ? entry.getValue() : null;
}
代码示例来源:origin: apache/incubator-druid
@Override
public T sample()
{
final double randomValue = random.nextDouble();
Integer valueIndex = probabilityRanges.floorEntry(randomValue).getValue();
return normalizedPmf.get(valueIndex).getFirst();
}
}
代码示例来源:origin: atomix/atomix
@Override
public Position lookup(long index) {
Map.Entry<Long, Integer> entry = positions.floorEntry(index);
return entry != null ? new Position(entry.getKey(), entry.getValue()) : null;
}
代码示例来源:origin: stackoverflow.com
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();
}
代码示例来源:origin: com.h2database/h2
@Override
public ByteBuffer readFully(long pos, int len) {
Entry<Long, ByteBuffer> memEntry = memory.floorEntry(pos);
if (memEntry == null) {
throw DataUtils.newIllegalStateException(
DataUtils.ERROR_READING_FAILED,
"Could not read from position {0}", pos);
}
readCount.incrementAndGet();
readBytes.addAndGet(len);
ByteBuffer buff = memEntry.getValue();
ByteBuffer read = buff.duplicate();
int offset = (int) (pos - memEntry.getKey());
read.position(offset);
read.limit(len + offset);
return read.slice();
}
代码示例来源:origin: apache/avro
public int segment(T value) {
Map.Entry<T, Integer> e = index.floorEntry(value);
if (e == null) {
throw new SegmenterException("Could not find bucket for: " + value);
}
return e.getValue();
}
代码示例来源:origin: apache/hbase
public boolean isModified(long procId) {
final Map.Entry<Long, BitSetNode> entry = map.floorEntry(procId);
return entry != null && entry.getValue().contains(procId) &&
entry.getValue().isModified(procId);
}
代码示例来源:origin: lealone/Lealone
@Override
public ByteBuffer readFully(long pos, int len) {
Entry<Long, ByteBuffer> memEntry = memory.floorEntry(pos);
if (memEntry == null) {
throw DataUtils.newIllegalStateException(DataUtils.ERROR_READING_FAILED, "Could not read from position {0}",
pos);
}
readCount++;
readBytes += len;
ByteBuffer buff = memEntry.getValue();
ByteBuffer read = buff.duplicate();
int offset = (int) (pos - memEntry.getKey());
read.position(offset);
read.limit(len + offset);
return read.slice();
}
代码示例来源:origin: robolectric/robolectric
@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);
}
}
代码示例来源:origin: apache/hive
private SortedMap<Long, Long> getAndValidateMissingChunks(
int maxAlloc, long from, long to) {
Map.Entry<Long, Long> firstMissing = chunkIndex.floorEntry(from);
if (firstMissing == null) {
throw new AssertionError("No lower bound for start offset " + from);
}
if (firstMissing.getValue() <= from
|| ((from - firstMissing.getKey()) % maxAlloc) != 0) {
// The data does not belong to a recognized chunk, or is split wrong.
throw new AssertionError("Lower bound for start offset " + from + " is ["
+ firstMissing.getKey() + ", " + firstMissing.getValue() + ")");
}
SortedMap<Long, Long> missingChunks = chunkIndex.subMap(firstMissing.getKey(), to);
if (missingChunks.isEmpty()) {
throw new AssertionError("No chunks for [" + from + ", " + to + ")");
}
long lastMissingOffset = missingChunks.lastKey(),
lastMissingEnd = missingChunks.get(lastMissingOffset);
if (lastMissingEnd < to
|| (to != lastMissingEnd && ((to - lastMissingOffset) % maxAlloc) != 0)) {
// The data does not belong to a recognized chunk, or is split wrong.
throw new AssertionError("Lower bound for end offset " + to + " is ["
+ lastMissingOffset + ", " + lastMissingEnd + ")");
}
return missingChunks;
}
代码示例来源:origin: EngineHub/WorldEdit
private double arcToParameter(double arc) {
if (cache.isEmpty())
throw new IllegalStateException("Must call setNodes first.");
if (arc > 1) arc = 1;
arc *= totalArcLength;
Entry<Double, Double> floorEntry = cache.floorEntry(arc);
final double leftArc = floorEntry.getKey();
final double leftParameter = floorEntry.getValue();
if (leftArc == arc) {
return leftParameter;
}
Entry<Double, Double> ceilingEntry = cache.ceilingEntry(arc);
if (ceilingEntry == null) {
log.warning("Error in arcToParameter: no ceiling entry for " + arc + " found!");
return 0;
}
final double rightArc = ceilingEntry.getKey();
final double rightParameter = ceilingEntry.getValue();
if (rightArc == arc) {
return rightParameter;
}
return evaluate(arc, leftArc, leftParameter, rightArc, rightParameter);
}
代码示例来源:origin: apache/hbase
/**
* If {@link #partial} is false, returns state from the bitmap. If no state is found for
* {@code procId}, returns YES.
* If partial is true, tracker doesn't have complete view of system state, so it returns MAYBE
* if there is no update for the procedure or if it doesn't have a state in bitmap. Otherwise,
* returns state from the bitmap.
*/
public DeleteState isDeleted(long procId) {
Map.Entry<Long, BitSetNode> entry = map.floorEntry(procId);
if (entry != null && entry.getValue().contains(procId)) {
BitSetNode node = entry.getValue();
DeleteState state = node.isDeleted(procId);
return partial && !node.isModified(procId) ? DeleteState.MAYBE : state;
}
return partial ? DeleteState.MAYBE : DeleteState.YES;
}
代码示例来源:origin: com.h2database/h2
@Override
public void writeFully(long pos, ByteBuffer src) {
fileSize = Math.max(fileSize, pos + src.remaining());
Entry<Long, ByteBuffer> mem = memory.floorEntry(pos);
if (mem == null) {
代码示例来源:origin: lealone/Lealone
@Override
public void writeFully(long pos, ByteBuffer src) {
fileSize = Math.max(fileSize, pos + src.remaining());
Entry<Long, ByteBuffer> mem = memory.floorEntry(pos);
if (mem == null) {
// not found: create a new entry
writeNewEntry(pos, src);
return;
}
long prevPos = mem.getKey();
ByteBuffer buff = mem.getValue();
int prevLength = buff.capacity();
int length = src.remaining();
if (prevPos == pos) {
if (prevLength != length) {
throw DataUtils.newIllegalStateException(DataUtils.ERROR_READING_FAILED,
"Could not write to position {0}; " + "partial overwrite is not supported", pos);
}
writeCount++;
writeBytes += length;
buff.rewind();
buff.put(src);
return;
}
if (prevPos + prevLength > pos) {
throw DataUtils.newIllegalStateException(DataUtils.ERROR_READING_FAILED,
"Could not write to position {0}; " + "partial overwrite is not supported", pos);
}
writeNewEntry(pos, src);
}
代码示例来源:origin: apache/hive
Map.Entry<Long, BlockLocation> startEntry = locations.floorEntry(offset);
BlockLocation start = startEntry.getValue();
if (offset + length <= start.getOffset() + start.getLength()) {
Map.Entry<Long, BlockLocation> endEntry = locations.floorEntry(offset + length);
代码示例来源:origin: apache/ignite
assert aliveSrvs.size() > 1 : aliveSrvs;
Map.Entry<Long, String> prevE = aliveSrvs.floorEntry(locInternalOrder - 1);
代码示例来源:origin: apache/incubator-druid
while (it.hasNext()) {
Interval interval = it.next().getInterval();
Map.Entry<Long, Long> floor = granularThresholds.floorEntry(granularity.bucketStart(interval.getStart()).getMillis());
if (floor == null || interval.getEndMillis() <= floor.getValue()) {
it.remove();
代码示例来源:origin: apache/ignite
assert aliveClients.size() > 1 : aliveClients;
Map.Entry<Long, String> prevE = aliveClients.floorEntry(locInternalOrder - 1);
代码示例来源:origin: apache/hbase
Map.Entry<Long, BitSetNode> leftEntry = map.floorEntry(procId);
if (leftEntry != null) {
leftNode = leftEntry.getValue();
内容来源于网络,如有侵权,请联系作者删除!