public static int calculateTableSize(
      float keyCountAdj, int threshold, float loadFactor, long keyCount) {
    if (keyCount >= 0 && keyCountAdj != 0) {
      // We have statistics for the table. Size appropriately.
      threshold = (int)Math.ceil(keyCount / (keyCountAdj * loadFactor));
    }
    LOG.info("Key count from statistics is " + keyCount + "; setting map size to " + threshold);
    return threshold;
  }
Simple wrapper for persistent Hashmap implementing only the put/get/remove/clear interface. The
main memory hash table acts as a cache and all put/get will operate on it first. If the size of
the main memory hash table exceeds a certain threshold, new elements will go into the persistent
hash table.
ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/HashMapWrapper.java