@Override
 public void close() {
   assert shardKeyMap.size() == 0 : shardKeyMap.size();
   assert shardStats.isEmpty() : shardStats.keySet();
   assert stats2.isEmpty() : stats2;
   cache.clear();
 }
  /** Clear all entries that belong to the given index. */
  public void clearIndex(String index) {
    final Set<Object> coreCacheKeys = shardKeyMap.getCoreKeysForIndex(index);
    for (Object coreKey : coreCacheKeys) {
      cache.clearCoreCacheKey(coreKey);
    }

    // This cache stores two things: filters, and doc id sets. Calling
    // clear only removes the doc id sets, but if we reach the situation
    // that the cache does not contain any DocIdSet anymore, then it
    // probably means that the user wanted to remove everything.
    if (cache.getCacheSize() == 0) {
      cache.clear();
    }
  }