public void refreshAggrPartitionColStats(AggrStats aggrStatsAllPartitions,
        AggrStats aggrStatsAllButDefaultPartition, SharedCache sharedCache, Map<List<String>, Long> partNameToWriteId) {
      Map<String, List<ColumnStatisticsObj>> newAggrColStatsCache = new HashMap<String, List<ColumnStatisticsObj>>();
      try {
        tableLock.writeLock().lock();
        int statsSize = 0;
        if (partNameToWriteId != null) {
          for (Entry<List<String>, Long> partValuesWriteIdSet : partNameToWriteId.entrySet()) {
            List<String> partValues = partValuesWriteIdSet.getKey();
            Partition partition = getPartition(partValues, sharedCache);
            if (partition == null) {
              LOG.info("Could not refresh the aggregate stat as partition " + partValues + " does not exist");
              return;
            }

            // for txn tables, if the write id is modified means the partition is updated post fetching of stats. So
            // skip updating the aggregate stats in the cache.
            long writeId = partition.getWriteId();
            if (writeId != partValuesWriteIdSet.getValue()) {
              LOG.info("Could not refresh the aggregate stat as partition " + partValues + " has write id "
                  + partValuesWriteIdSet.getValue() + " instead of " + writeId);
              return;
            }
          }
        }
        if (aggrStatsAllPartitions != null) {
          for (ColumnStatisticsObj statObj : aggrStatsAllPartitions.getColStats()) {
            if (compareAndSetMemberCacheUpdated(MemberName.AGGR_COL_STATS_CACHE, true, false)) {
              LOG.debug("Skipping aggregate stats cache update for table: " + getTable().getTableName()
                  + "; the aggregate stats list we have is dirty");
              return;
            }
            if (statObj != null) {
              List<ColumnStatisticsObj> aggrStats = new ArrayList<ColumnStatisticsObj>();
              aggrStats.add(StatsType.ALL.ordinal(), statObj.deepCopy());
              newAggrColStatsCache.put(statObj.getColName(), aggrStats);
              statsSize += getObjectSize(ColumnStatisticsObj.class, statObj);
            }
          }
        }
        if (aggrStatsAllButDefaultPartition != null) {
          for (ColumnStatisticsObj statObj : aggrStatsAllButDefaultPartition.getColStats()) {
            if (compareAndSetMemberCacheUpdated(MemberName.AGGR_COL_STATS_CACHE, true, false)) {
              LOG.debug("Skipping aggregate stats cache update for table: " + getTable().getTableName()
                  + "; the aggregate stats list we have is dirty");
              return;
            }
            if (statObj != null) {
              List<ColumnStatisticsObj> aggrStats = newAggrColStatsCache.get(statObj.getColName());
              if (aggrStats == null) {
                aggrStats = new ArrayList<ColumnStatisticsObj>();
              }
              aggrStats.add(StatsType.ALLBUTDEFAULT.ordinal(), statObj.deepCopy());
              statsSize += getObjectSize(ColumnStatisticsObj.class, statObj);
            }
          }
        }
        aggrColStatsCache = newAggrColStatsCache;
        updateMemberSize(MemberName.AGGR_COL_STATS_CACHE, statsSize, SizeMode.Snapshot);
      } finally {
        tableLock.writeLock().unlock();
      }
    }
Common method to refresh cache constraint
@param constraints list of constraints to update
@param mn Constraint type
@return Since memory constraint is handled by cache eviction policy.
Hence this method will always return true if correct constraint type passed.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/SharedCache.java