创建移植自Netty的key为long的优化HashMap

@param initialCapacity 默认为8
@param loadFactor 默认为0.5
185071
public static <V> LongObjectHashMap<V> createPrimitiveLongKeyMap(int initialCapacity, float loadFactor) {
		return new LongObjectHashMap<V>(initialCapacity, loadFactor);
	}
56251
public static <K, V> Map<K, V> createLinkedHashMap(int expectedMapSize) {
        final int initialCapacity = calculateInitialCapacity(expectedMapSize);
        return new LinkedHashMap<K, V>(initialCapacity, HASHMAP_DEFAULT_LOAD_FACTOR);
    }
496984
private void loadStorageForFetch(CodeBuilder b, TypeDesc type) {
        b.loadThis();
        b.loadField(SUPPORT_FIELD_NAME, mSupportType);
        TypeDesc storageType = TypeDesc.forClass(Storage.class);

        TypeDesc repositoryType = TypeDesc.forClass(Repository.class);
        b.invokeInterface
            (mSupportType, "getRootRepository", repositoryType, null);
        b.loadConstant(type);

        // This may throw a RepositoryException.
        Label tryStart = b.createLabel().setLocation();
        b.invokeInterface(repositoryType, STORAGE_FOR_METHOD_NAME, storageType,
                          new TypeDesc[]{TypeDesc.forClass(Class.class)});
        Label tryEnd = b.createLabel().setLocation();
        Label noException = b.createLabel();
        b.branch(noException);

        b.exceptionHandler(tryStart, tryEnd,
                           RepositoryException.class.getName());
        b.invokeVirtual
            (RepositoryException.class.getName(), "toFetchException",
             TypeDesc.forClass(FetchException.class), null);
        b.throwObject();

        noException.setLocation();
    }
523778
public static <K, V> Map<K, V> createHashMap(int expectedMapSize) {
        final int initialCapacity = calculateInitialCapacity(expectedMapSize);
        return new HashMap<K, V>(initialCapacity, HASHMAP_DEFAULT_LOAD_FACTOR);
    }
852948
public static Initializer defaultInitializer() {
      return newInitializer()
              .setCloseConcurrency(0)
              .setTestOnLogicalOpen(false)
              .setTestOnLogicalClose(false)
              .setIncompleteTransactionOnClosePolicy(ConnectionPoolConnection.IncompleteTransactionPolicy.REPORT)
              .setOpenStatementOnClosePolicy(ConnectionPoolConnection.OpenStatementPolicy.REPORT)
              .setForceRealClosePolicy(ConnectionPoolConnection.ForceRealClosePolicy.CONNECTION_WITH_LIMIT)
              .setActivityTimeoutPolicy(ConnectionPoolConnection.ActivityTimeoutPolicy.LOG)
              .setCloseTimeLimitMillis(10 * 1000L)
              .setActiveTimeout(60, TimeUnit.SECONDS)
              .setConnectionLifetime(15, TimeUnit.MINUTES)
              .setMaxConcurrentReconnects(2)
              .setMaxReconnectDelay(1, TimeUnit.MINUTES)
              .setActiveTimeoutMonitorFrequency(30, TimeUnit.SECONDS);
   }
1259904
public CacheSpec<K, V> loadingFunction(Function<K, V> loadingFunction) {
      this.cacheFunction = loadingFunction;
      return this;
   }
1312787
private Map<String, String> toPayload(Map<String, Object> data) throws LocalOperationException {
        Map<String, Object> dataClone = new HashMap<String, Object>(data);
        dataClone.put("auth", getAuthData());

        Map<String, String> payload = new HashMap<String, String>();
        payload.put("params", jsonifyData(dataClone));

        if (transloadit.shouldSignRequest) {
            payload.put("signature", getSignature(jsonifyData(dataClone)));
        }
        return payload;
    }
1270557
function MemoryAdapter(initialFiles) {
    if (!(this instanceof MemoryAdapter)) {
        return new MemoryAdapter(initialFiles);
    }

    this.entries = new Map();

    // load initial file buffers
    if (typeof initialFiles === "object" && initialFiles) {
        Object.keys(initialFiles).forEach((fileName) => {
            const buf = Buffer.from(initialFiles[fileName]);
            this.entries.set(fileName, buf);
        });
    }
}
236632
@Override
	public void init(Key key, IvParameterSpec iv) throws InvalidKeyException {
		if(!(key instanceof SecretKey))
			throw new InvalidKeyException();
		int ivLength = iv.getIV().length;
		if(key.getEncoded().length < MIN_KEY_SIZE || key.getEncoded().length < ivLength)
			throw new InvalidKeyException("Key must be longer than " + MIN_KEY_SIZE + " bytes and key must be longer than IV.");
		this.key = key.getEncoded();
		this.iv = iv;
		prehash = Misc.XORintoA(this.key.length == ivLength ? iv.getIV() : Arrays.copyOf(iv.getIV(), this.key.length), this.key);
		blockNo = 0;
		buffer = new ByteQueue(getBlockSize()*2);
		buffer.setResizable(true);
		cfg = true;
	}
718861
public static <K, V> ArrayMap<K, V> create(int initialCapacity) {
    ArrayMap<K, V> result = create();
    result.ensureCapacity(initialCapacity);
    return result;
  }
1089432
public void setInitializationVector(String initializationVector) {
		try {
			this.initializationVectorSpec = new IvParameterSpec(Base64.decodeBase64(initializationVector.getBytes("UTF-8")));
		} catch (UnsupportedEncodingException e) {
			throw new SymmetricEncryptionException("UTF-8 is an unsupported encoding on this platform", e);
		}
	}
989917
function initializeWithEval() {
  var dbTest = new loki('perfInsertWithEval');

  var start, end, totalTime;
  var totalTimes = [];
  var totalMS = 0.0;

  var coll = dbTest.addCollection('samplecoll',
    {
      indices: ['customId'],
      asyncListeners: false,
      disableChangesApi: true,
      transactional: false,
      clone: false
    }
  );

  var dv = coll.addDynamicView('test');
  dv.applyFind({'customId': {'$lt': arraySize/4 }});

  for (var idx=0; idx < arraySize; idx++) {
    var v1 = genRandomVal();
    var v2 = genRandomVal();

    start = performance.now();
    coll.insert({
      customId: idx,
      val: v1,
      val2: v2,
      val3: "more data 1234567890"
    });
    end = performance.now() - start;
    totalTimes.push([0, end * 1e6]);
  }

  for(idx=0; idx < totalTimes.length; idx++) {
    totalMS += totalTimes[idx][0] * 1e3 + totalTimes[idx][1]/1e6;
  }

  totalMS = totalMS.toFixed(2);
  var rate = arraySize * 1000 / totalMS;
  rate = rate.toFixed(2);
  trace("load (insert with dynamic view registered) : " + totalMS + "ms (" + rate + ") ops/s");
}
1117072
public static <K> HashMap<K, MutableLong> createMutableLongValueMap(int initialCapacity, float loadFactor) {
		return new HashMap<K, MutableLong>(initialCapacity, loadFactor);
	}
17361
public static <K, V> LinkedHashMultimap<K, V> create() {
    return new LinkedHashMultimap<K, V>(DEFAULT_KEY_CAPACITY, DEFAULT_VALUE_SET_CAPACITY);
  }
846905
public static <K, V> ConcurrentMap<K, V> createWeakValueConcurrentMap(int initialCapacity, int concurrencyLevel) {
		return new MapMaker().weakValues().initialCapacity(initialCapacity).concurrencyLevel(concurrencyLevel)
				.makeMap();
	}
274863
protected void buildCache(int maxCacheSize) {
        if (blackPrefixList != null && !blackPrefixList.isEmpty()) {
            int min = Math.min(256, maxCacheSize);
            int max = Math.min(10240, maxCacheSize);
            ConcurrentLinkedHashMap.Builder<String, Boolean> builder = new ConcurrentLinkedHashMap.Builder<String, Boolean>()
                .initialCapacity(min).maximumWeightedCapacity(max);
            this.resultOfInBlackList = builder.build();
        } else {
            this.resultOfInBlackList = null;
        }
    }
1180620
@Override
  protected void rebuild(final int newCapacity) {
    final int numValues = getNumValues();
    checkIfEnoughMemory(mem_, newCapacity, numValues);
    final int currCapacity = getCurrentCapacity();
    final long[] keys = new long[currCapacity];
    final double[] values = new double[currCapacity * numValues];
    mem_.getLongArray(keysOffset_, keys, 0, currCapacity);
    mem_.getDoubleArray(valuesOffset_, values, 0, currCapacity * numValues);
    mem_.clear(keysOffset_,
        ((long) SIZE_OF_KEY_BYTES * newCapacity) + ((long) SIZE_OF_VALUE_BYTES * newCapacity * numValues));
    mem_.putInt(RETAINED_ENTRIES_INT, 0);
    mem_.putByte(LG_CUR_CAPACITY_BYTE, (byte)Integer.numberOfTrailingZeros(newCapacity));
    valuesOffset_ = keysOffset_ + (SIZE_OF_KEY_BYTES * newCapacity);
    lgCurrentCapacity_ = Integer.numberOfTrailingZeros(newCapacity);
    for (int i = 0; i < keys.length; i++) {
      if ((keys[i] != 0) && (keys[i] < theta_)) {
        insert(keys[i], Arrays.copyOfRange(values, i * numValues, (i + 1) * numValues));
      }
    }
    setRebuildThreshold();
  }