private static void initSizeEstimator() {
    sizeEstimator = new HashMap<>();
    IncrementalObjectSizeEstimator.createEstimators(CacheKey.class, sizeEstimator);
    for (KeyType e : KeyType.values()) {
      for (Class<?> c : e.keyClasses) {
        IncrementalObjectSizeEstimator.createEstimators(c, sizeEstimator);
      }
      IncrementalObjectSizeEstimator.createEstimators(e.valueClass, sizeEstimator);
    }
  }
This class introduces a caching layer in HS2 for metadata for some selected query APIs. It extends
HiveMetaStoreClient, and overrides some of its methods to add this feature.
Its design is simple, relying on snapshot information being queried to cache and invalidate the metadata.
It helps to reduce the time spent in compilation by using HS2 memory more effectively, and it allows to
improve HMS throughput for multi-tenant workloads by reducing the number of calls it needs to serve.
ql/src/java/org/apache/hadoop/hive/ql/metadata/HiveMetaStoreClientWithLocalCache.java