本文整理匯總了Java中java.util.concurrent.ConcurrentNavigableMap.floorEntry方法的典型用法代碼示例。如果您正苦於以下問題:Java ConcurrentNavigableMap.floorEntry方法的具體用法?Java ConcurrentNavigableMap.floorEntry怎麽用?Java ConcurrentNavigableMap.floorEntry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.concurrent.ConcurrentNavigableMap
的用法示例。
在下文中一共展示了ConcurrentNavigableMap.floorEntry方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testFloorEntry
import java.util.concurrent.ConcurrentNavigableMap; //導入方法依賴的package包/類
/**
* floorEntry returns preceding entry.
*/
public void testFloorEntry() {
ConcurrentNavigableMap map = map5();
Map.Entry e1 = map.floorEntry(three);
assertEquals(three, e1.getKey());
Map.Entry e2 = map.floorEntry(six);
assertEquals(five, e2.getKey());
Map.Entry e3 = map.floorEntry(one);
assertEquals(one, e3.getKey());
Map.Entry e4 = map.floorEntry(zero);
assertNull(e4);
}
示例2: testDescendingFloorEntry
import java.util.concurrent.ConcurrentNavigableMap; //導入方法依賴的package包/類
/**
* floorEntry returns preceding entry.
*/
public void testDescendingFloorEntry() {
ConcurrentNavigableMap map = dmap5();
Map.Entry e1 = map.floorEntry(m3);
assertEquals(m3, e1.getKey());
Map.Entry e2 = map.floorEntry(m6);
assertEquals(m5, e2.getKey());
Map.Entry e3 = map.floorEntry(m1);
assertEquals(m1, e3.getKey());
Map.Entry e4 = map.floorEntry(zero);
assertNull(e4);
}
示例3: getCachedLocation
import java.util.concurrent.ConcurrentNavigableMap; //導入方法依賴的package包/類
/**
* Search the cache for a location that fits our table and row key.
* Return null if no suitable region is located.
*
* @return Null or region location found in cache.
*/
public RegionLocations getCachedLocation(final TableName tableName, final byte [] row) {
ConcurrentNavigableMap<byte[], RegionLocations> tableLocations =
getTableLocations(tableName);
Entry<byte[], RegionLocations> e = tableLocations.floorEntry(row);
if (e == null) {
if (metrics!= null) metrics.incrMetaCacheMiss();
return null;
}
RegionLocations possibleRegion = e.getValue();
// make sure that the end key is greater than the row we're looking
// for, otherwise the row actually belongs in the next region, not
// this one. the exception case is when the endkey is
// HConstants.EMPTY_END_ROW, signifying that the region we're
// checking is actually the last region in the table.
byte[] endKey = possibleRegion.getRegionLocation().getRegionInfo().getEndKey();
if (Bytes.equals(endKey, HConstants.EMPTY_END_ROW) ||
getRowComparator(tableName).compareRows(
endKey, 0, endKey.length, row, 0, row.length) > 0) {
if (metrics != null) metrics.incrMetaCacheHit();
return possibleRegion;
}
// Passed all the way through, so we got nothing - complete cache miss
if (metrics != null) metrics.incrMetaCacheMiss();
return null;
}