當前位置: 首頁>>代碼示例>>Java>>正文


Java NavigableMap.get方法代碼示例

本文整理匯總了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);
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:SizeConfigStrategy.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:LruArrayPool.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:LruArrayPool.java

示例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;
}
 
開發者ID:hotpads,項目名稱:datarouter,代碼行數:21,代碼來源:EntityTool.java

示例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);
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:34,代碼來源:HBaseSink.java

示例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;
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:30,代碼來源:ComponentServiceImpl.java

示例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;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:23,代碼來源:ScopeWALEntryFilter.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:SizeConfigStrategy.java

示例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);
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:LruArrayPool.java

示例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;
}
 
開發者ID:hotpads,項目名稱:datarouter,代碼行數:16,代碼來源:EntityTool.java

示例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) {}
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:TreeSubMapTest.java

示例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) {}
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:TreeSubMapTest.java

示例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);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:44,代碼來源:MetaTableAccessor.java

示例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&amp;family,Map&lt;qualifier,Map&lt;timestamp,value&gt;&gt;&gt;</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;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:45,代碼來源:Result.java

示例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;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:54,代碼來源:TableEventHandler.java


注:本文中的java.util.NavigableMap.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。