public void cacheThreadLocalRawStore() {
    Long threadId = this.getId();
    RawStore threadLocalRawStore = HMSHandler.getRawStore();
    if (threadLocalRawStore == null) {
      LOG.debug("Thread Local RawStore is null, for the thread: " +
              this.getName() + " and so removing entry from threadRawStoreMap.");
      threadRawStoreMap.remove(threadId);
    } else {
      LOG.debug("Adding RawStore: " + threadLocalRawStore + ", for the thread: " +
          this.getName() + " to threadRawStoreMap for future cleanup.");
      threadRawStoreMap.put(threadId, threadLocalRawStore);
    }
  }
Cache the ThreadLocal RawStore object. Called from the corresponding thread.
service/src/java/org/apache/hive/service/server/ThreadWithGarbageCleanup.java