Java源码示例:com.carrotsearch.hppc.IntLongHashMap

示例1
/**
 * Create map with expected max value of key.
 * Although the map will automatically do resizing to be able to hold key {@code >=g expectedKeyMax}.
 * But putting key much larger than {@code expectedKeyMax} is discourage since it can leads to use LOT OF memory.
 */
public IntLongDynamicMap(int expectedKeyMax, long emptyValue) {
  this.threshold = threshold(expectedKeyMax);
  this.maxSize = expectedKeyMax;
  this.emptyValue = emptyValue;
  if (useArrayBased(expectedKeyMax)) {
    upgradeToArray();
  } else {
    this.hashMap = new IntLongHashMap(mapExpectedElements(expectedKeyMax));
  }
}
 
示例2
public IntScoreCollector(int maxDoc,
                         int segments,
                         int nullValue,
                         int nullPolicy,
                         int size,
                         String field,
                         IntIntHashMap boostDocsMap,
                         IndexSearcher searcher) {
  this.maxDoc = maxDoc;
  this.contexts = new LeafReaderContext[segments];
  List<LeafReaderContext> con = searcher.getTopReaderContext().leaves();
  for(int i=0; i<con.size(); i++) {
    contexts[i] = con.get(i);
  }

  this.collapsedSet = new FixedBitSet(maxDoc);
  this.nullValue = nullValue;
  this.nullPolicy = nullPolicy;
  if(nullPolicy == CollapsingPostFilter.NULL_POLICY_EXPAND) {
    nullScores = new FloatArrayList();
  }
  this.cmap = new IntLongHashMap(size);
  this.field = field;

  if(boostDocsMap != null) {
    this.boosts = true;
    this.boostDocs = new IntArrayList();
    this.boostKeys = new IntArrayList();
    int[] bd = new int[boostDocsMap.size()];
    Iterator<IntIntCursor> it =  boostDocsMap.iterator();
    int index = -1;
    while(it.hasNext()) {
      IntIntCursor cursor = it.next();
      bd[++index] = cursor.key;
    }

    Arrays.sort(bd);
    this.mergeBoost = new MergeBoost(bd);
    this.boosts = true;
  }

}