void selectRawHostAccountStorageStatsMap(
      Map<Long, Map<Short, Map<Short, ContainerStorageStats>>> selectedHostAccountStorageStatsMap,
      Map<Long, Map<Short, Map<Short, ContainerStorageStats>>> hostAccountStorageStatsMap,
      Map<Long, Long> partitionTimestampMap, Map<Long, Long> partitionPhysicalStorageMap, long snapshotTimestamp,
      String instanceName) {
    for (Map.Entry<Long, Map<Short, Map<Short, ContainerStorageStats>>> hostAccountStorageStatsMapEntry : hostAccountStorageStatsMap
        .entrySet()) {
      long partitionId = hostAccountStorageStatsMapEntry.getKey();
      if (!selectedHostAccountStorageStatsMap.containsKey(partitionId)) {
        logger.trace("First entry for partition {} is from {}", partitionId, instanceName);
        selectedHostAccountStorageStatsMap.put(partitionId, hostAccountStorageStatsMapEntry.getValue());
        partitionTimestampMap.put(partitionId, snapshotTimestamp);
      } else {
        long existingValue = partitionPhysicalStorageMap.computeIfAbsent(partitionId,
            k -> sumPhysicalStorageUsage(selectedHostAccountStorageStatsMap.get(partitionId)));
        long currentValue = sumPhysicalStorageUsage(hostAccountStorageStatsMapEntry.getValue());
        long deltaInValue = currentValue - existingValue;
        long deltaInTimeMs = snapshotTimestamp - partitionTimestampMap.get(partitionId);
        if (Math.abs(deltaInTimeMs) < relevantTimePeriodInMs && deltaInValue > 0) {
          logger.trace("Updating partition {} storage stats from instance {} as last updated time is within"
              + "relevant time period and delta value has increased ", partitionId, instanceName);
          selectedHostAccountStorageStatsMap.put(partitionId, hostAccountStorageStatsMapEntry.getValue());
          partitionPhysicalStorageMap.put(partitionId, currentValue);
          partitionTimestampMap.put(partitionId, snapshotTimestamp);
        } else if (deltaInTimeMs > relevantTimePeriodInMs) {
          logger.trace("Updating partition {} snapshot from instance {} as new value is updated "
              + "within relevant time period compared to already existing one", partitionId, instanceName);
          selectedHostAccountStorageStatsMap.put(partitionId, hostAccountStorageStatsMapEntry.getValue());
          partitionPhysicalStorageMap.put(partitionId, currentValue);
          partitionTimestampMap.put(partitionId, snapshotTimestamp);
        } else {
          logger.trace("Ignoring snapshot from {} for partition {}", instanceName, partitionId);
        }
      }
    }
  }
Select the proper replica's account storage stats map the merge to the first map.
@param selectedHostAccountStorageStatsMap The result map merged with proper replica's storage stats data.
@param hostAccountStorageStatsMap Single host's storage stats map.
@param partitionTimestampMap The map from partition id to the partition's snapshot timestamp.
@param partitionPhysicalStorageMap The map from partition id to the partition's physical storage usage.
@param snapshotTimestamp The snapshot timestamp for the given host.
@param instanceName The host's instance name.
ambry-clustermap/src/main/java/com/github/ambry/clustermap/MySqlClusterAggregator.java