本文整理汇总了Java中java.util.NavigableMap.get方法的典型用法代码示例。如果您正苦于以下问题:Java NavigableMap.get方法的具体用法?Java NavigableMap.get怎么用?Java NavigableMap.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.NavigableMap
的用法示例。
在下文中一共展示了NavigableMap.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decrementBitmapOfSize
import java.util.NavigableMap; //导入方法依赖的package包/类
private void decrementBitmapOfSize(Integer size, Bitmap removed) {
Bitmap.Config config = removed.getConfig();
NavigableMap<Integer, Integer> sizes = getSizesForConfig(config);
Integer current = sizes.get(size);
if (current == null) {
throw new NullPointerException("Tried to decrement empty size"
+ ", size: " + size
+ ", removed: " + logBitmap(removed)
+ ", this: " + this);
}
if (current == 1) {
sizes.remove(size);
} else {
sizes.put(size, current - 1);
}
}
示例2: put
import java.util.NavigableMap; //导入方法依赖的package包/类
@Override
public synchronized <T> void put(T array, Class<T> arrayClass) {
ArrayAdapterInterface<T> arrayAdapter = getAdapterFromType(arrayClass);
int size = arrayAdapter.getArrayLength(array);
int arrayBytes = size * arrayAdapter.getElementSizeInBytes();
if (!isSmallEnoughForReuse(arrayBytes)) {
return;
}
Key key = keyPool.get(size, arrayClass);
groupedMap.put(key, array);
NavigableMap<Integer, Integer> sizes = getSizesForAdapter(arrayClass);
Integer current = sizes.get(key.size);
sizes.put(key.size, current == null ? 1 : current + 1);
currentSize += arrayBytes;
evict();
}
示例3: put
import java.util.NavigableMap; //导入方法依赖的package包/类
@Override
public synchronized <T> void put(T array) {
@SuppressWarnings("unchecked")
Class<T> arrayClass = (Class<T>) array.getClass();
ArrayAdapterInterface<T> arrayAdapter = getAdapterFromType(arrayClass);
int size = arrayAdapter.getArrayLength(array);
int arrayBytes = size * arrayAdapter.getElementSizeInBytes();
if (!isSmallEnoughForReuse(arrayBytes)) {
return;
}
Key key = keyPool.get(size, arrayClass);
groupedMap.put(key, array);
NavigableMap<Integer, Integer> sizes = getSizesForAdapter(arrayClass);
Integer current = sizes.get(key.size);
sizes.put(key.size, current == null ? 1 : current + 1);
currentSize += arrayBytes;
evict();
}
示例4: getDatabeansByEntityKey
import java.util.NavigableMap; //导入方法依赖的package包/类
public static <EK extends EntityKey<EK>,
PK extends EntityPrimaryKey<EK,PK>,
D extends Databean<PK,D>>
NavigableMap<EK,List<D>> getDatabeansByEntityKey(Iterable<D> databeans){
NavigableMap<EK,List<D>> databeansByEntityKey = new TreeMap<>();
for(D databean : IterableTool.nullSafe(databeans)){
if(databean == null){
continue;
}// seem to be getting some null entries from TraceFlushController?
PK pk = databean.getKey();//leave on individual line for NPE trace
EK ek = pk.getEntityKey();
List<D> databeansForEntity = databeansByEntityKey.get(ek);
if(databeansForEntity == null){
databeansForEntity = new ArrayList<>();
databeansByEntityKey.put(ek, databeansForEntity);
}
databeansForEntity.add(databean);
}
return databeansByEntityKey;
}
示例5: incrementCounter
import java.util.NavigableMap; //导入方法依赖的package包/类
/**
* Helper function for {@link #coalesceIncrements} to increment a counter
* value in the passed data structure.
*
* @param counters Nested data structure containing the counters.
* @param row Row key to increment.
* @param family Column family to increment.
* @param qualifier Column qualifier to increment.
* @param count Amount to increment by.
*/
private void incrementCounter(
Map<byte[], Map<byte[], NavigableMap<byte[], Long>>> counters,
byte[] row, byte[] family, byte[] qualifier, Long count) {
Map<byte[], NavigableMap<byte[], Long>> families = counters.get(row);
if (families == null) {
families = Maps.newTreeMap(Bytes.BYTES_COMPARATOR);
counters.put(row, families);
}
NavigableMap<byte[], Long> qualifiers = families.get(family);
if (qualifiers == null) {
qualifiers = Maps.newTreeMap(Bytes.BYTES_COMPARATOR);
families.put(family, qualifiers);
}
Long existingValue = qualifiers.get(qualifier);
if (existingValue == null) {
qualifiers.put(qualifier, count);
} else {
qualifiers.put(qualifier, existingValue + count);
}
}
示例6: findExtensions
import java.util.NavigableMap; //导入方法依赖的package包/类
/**
* Finds extensions in the project sources and returns a mapping from the extension type name (for
* old style extensions) or package name (for new style extensions) to the set of file names
* included in that extension.
*
* @param extensionDir Extension asset directory in the project
* @param files Set of all file names in the project
* @return A map from the type name or package name of an extension to a set of all files in that
* extension. We return a NavigableMap to aid in searching for related extensions during an
* upgrade when the two extensions might share the same package but have been packaged by the
* old extension system, which was per-class rather than per-package.
*/
private static NavigableMap<String, Set<String>> findExtensions(String extensionDir,
Set<String> files) {
NavigableMap<String, Set<String>> extensions = new TreeMap<>();
for (String s : files) {
if (s.startsWith(extensionDir)) {
String[] parts = s.split("/");
String extensionName = parts[2];
Set<String> extFiles = extensions.get(extensionName);
if (extFiles == null) {
extFiles = new HashSet<>();
extensions.put(extensionName, extFiles);
}
extFiles.add(s);
}
}
return extensions;
}
示例7: filter
import java.util.NavigableMap; //导入方法依赖的package包/类
@Override
public Entry filter(Entry entry) {
NavigableMap<byte[], Integer> scopes = entry.getKey().getScopes();
if (scopes == null || scopes.isEmpty()) {
return null;
}
ArrayList<Cell> cells = entry.getEdit().getCells();
int size = cells.size();
for (int i = size - 1; i >= 0; i--) {
Cell cell = cells.get(i);
// The scope will be null or empty if
// there's nothing to replicate in that WALEdit
if (!scopes.containsKey(cell.getFamily())
|| scopes.get(cell.getFamily()) == HConstants.REPLICATION_SCOPE_LOCAL) {
cells.remove(i);
}
}
if (cells.size() < size / 2) {
cells.trimToSize();
}
return entry;
}
示例8: put
import java.util.NavigableMap; //导入方法依赖的package包/类
@Override
public void put(Bitmap bitmap) {
int size = Util.getBitmapByteSize(bitmap);
Key key = keyPool.get(size, bitmap.getConfig());
groupedMap.put(key, bitmap);
NavigableMap<Integer, Integer> sizes = getSizesForConfig(bitmap.getConfig());
Integer current = sizes.get(key.size);
sizes.put(key.size, current == null ? 1 : current + 1);
}
示例9: decrementArrayOfSize
import java.util.NavigableMap; //导入方法依赖的package包/类
private void decrementArrayOfSize(int size, Class<?> arrayClass) {
NavigableMap<Integer, Integer> sizes = getSizesForAdapter(arrayClass);
Integer current = sizes.get(size);
if (current == null) {
throw new NullPointerException(
"Tried to decrement empty size" + ", size: " + size + ", this: " + this);
}
if (current == 1) {
sizes.remove(size);
} else {
sizes.put(size, current - 1);
}
}
示例10: getPrimaryKeysByEntityKey
import java.util.NavigableMap; //导入方法依赖的package包/类
public static <EK extends EntityKey<EK>,
PK extends EntityPrimaryKey<EK,PK>>
NavigableMap<EK,List<PK>> getPrimaryKeysByEntityKey(Iterable<PK> pks){
NavigableMap<EK,List<PK>> pksByEntityKey = new TreeMap<>();
for(PK pk : IterableTool.nullSafe(pks)){
EK ek = pk.getEntityKey();
List<PK> pksForEntity = pksByEntityKey.get(ek);
if(pksForEntity == null){
pksForEntity = new ArrayList<>();
pksByEntityKey.put(ek, pksForEntity);
}
pksForEntity.add(pk);
}
return pksByEntityKey;
}
示例11: testGet_NullPointerException
import java.util.NavigableMap; //导入方法依赖的package包/类
/**
* get(null) of nonempty map throws NPE
*/
public void testGet_NullPointerException() {
NavigableMap c = map5();
try {
c.get(null);
shouldThrow();
} catch (NullPointerException success) {}
}
示例12: testDescendingGet_NullPointerException
import java.util.NavigableMap; //导入方法依赖的package包/类
/**
* get(null) of nonempty map throws NPE
*/
public void testDescendingGet_NullPointerException() {
NavigableMap c = dmap5();
try {
c.get(null);
shouldThrow();
} catch (NullPointerException success) {}
}
示例13: getRegionLocations
import java.util.NavigableMap; //导入方法依赖的package包/类
/**
* Returns an HRegionLocationList extracted from the result.
* @return an HRegionLocationList containing all locations for the region range or null if
* we can't deserialize the result.
*/
public static RegionLocations getRegionLocations(final Result r) {
if (r == null) return null;
HRegionInfo regionInfo = getHRegionInfo(r, getRegionInfoColumn());
if (regionInfo == null) return null;
List<HRegionLocation> locations = new ArrayList<HRegionLocation>(1);
NavigableMap<byte[],NavigableMap<byte[],byte[]>> familyMap = r.getNoVersionMap();
locations.add(getRegionLocation(r, regionInfo, 0));
NavigableMap<byte[], byte[]> infoMap = familyMap.get(getFamily());
if (infoMap == null) return new RegionLocations(locations);
// iterate until all serverName columns are seen
int replicaId = 0;
byte[] serverColumn = getServerColumn(replicaId);
SortedMap<byte[], byte[]> serverMap = null;
serverMap = infoMap.tailMap(serverColumn, false);
if (serverMap.isEmpty()) return new RegionLocations(locations);
for (Map.Entry<byte[], byte[]> entry : serverMap.entrySet()) {
replicaId = parseReplicaIdFromServerColumn(entry.getKey());
if (replicaId < 0) {
break;
}
HRegionLocation location = getRegionLocation(r, regionInfo, replicaId);
// In case the region replica is newly created, it's location might be null. We usually do not
// have HRL's in RegionLocations object with null ServerName. They are handled as null HRLs.
if (location == null || location.getServerName() == null) {
locations.add(null);
} else {
locations.add(location);
}
}
return new RegionLocations(locations);
}
示例14: getMap
import java.util.NavigableMap; //导入方法依赖的package包/类
/**
* Map of families to all versions of its qualifiers and values.
* <p>
* Returns a three level Map of the form:
* <code>Map&family,Map<qualifier,Map<timestamp,value>>></code>
* <p>
* Note: All other map returning methods make use of this map internally.
* @return map from families to qualifiers to versions
*/
public NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> getMap() {
if (this.familyMap != null) {
return this.familyMap;
}
if(isEmpty()) {
return null;
}
this.familyMap = new TreeMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>>(Bytes.BYTES_COMPARATOR);
for(Cell kv : this.cells) {
byte [] family = CellUtil.cloneFamily(kv);
NavigableMap<byte[], NavigableMap<Long, byte[]>> columnMap =
familyMap.get(family);
if(columnMap == null) {
columnMap = new TreeMap<byte[], NavigableMap<Long, byte[]>>
(Bytes.BYTES_COMPARATOR);
familyMap.put(family, columnMap);
}
byte [] qualifier = CellUtil.cloneQualifier(kv);
NavigableMap<Long, byte[]> versionMap = columnMap.get(qualifier);
if(versionMap == null) {
versionMap = new TreeMap<Long, byte[]>(new Comparator<Long>() {
@Override
public int compare(Long l1, Long l2) {
return l2.compareTo(l1);
}
});
columnMap.put(qualifier, versionMap);
}
Long timestamp = kv.getTimestamp();
byte [] value = CellUtil.cloneValue(kv);
versionMap.put(timestamp, value);
}
return this.familyMap;
}
示例15: reOpenAllRegions
import java.util.NavigableMap; //导入方法依赖的package包/类
public boolean reOpenAllRegions(List<HRegionInfo> regions) throws IOException {
boolean done = false;
LOG.info("Bucketing regions by region server...");
List<HRegionLocation> regionLocations = null;
Connection connection = this.masterServices.getConnection();
try (RegionLocator locator = connection.getRegionLocator(tableName)) {
regionLocations = locator.getAllRegionLocations();
}
// Convert List<HRegionLocation> to Map<HRegionInfo, ServerName>.
NavigableMap<HRegionInfo, ServerName> hri2Sn = new TreeMap<HRegionInfo, ServerName>();
for (HRegionLocation location: regionLocations) {
hri2Sn.put(location.getRegionInfo(), location.getServerName());
}
TreeMap<ServerName, List<HRegionInfo>> serverToRegions = Maps.newTreeMap();
List<HRegionInfo> reRegions = new ArrayList<HRegionInfo>();
for (HRegionInfo hri : regions) {
ServerName sn = hri2Sn.get(hri);
// Skip the offlined split parent region
// See HBASE-4578 for more information.
if (null == sn) {
LOG.info("Skip " + hri);
continue;
}
if (!serverToRegions.containsKey(sn)) {
LinkedList<HRegionInfo> hriList = Lists.newLinkedList();
serverToRegions.put(sn, hriList);
}
reRegions.add(hri);
serverToRegions.get(sn).add(hri);
}
LOG.info("Reopening " + reRegions.size() + " regions on "
+ serverToRegions.size() + " region servers.");
this.masterServices.getAssignmentManager().setRegionsToReopen(reRegions);
BulkReOpen bulkReopen = new BulkReOpen(this.server, serverToRegions,
this.masterServices.getAssignmentManager());
while (true) {
try {
if (bulkReopen.bulkReOpen()) {
done = true;
break;
} else {
LOG.warn("Timeout before reopening all regions");
}
} catch (InterruptedException e) {
LOG.warn("Reopen was interrupted");
// Preserve the interrupt.
Thread.currentThread().interrupt();
break;
}
}
return done;
}