private void deleteContainerAccountStats(Map<Long, Map<Short, Map<Short, ContainerStorageStats>>> prevPartitionMap,
      Map<Long, Map<Short, Map<Short, ContainerStorageStats>>> currPartitionMap) throws SQLException {
    long deleteStartTimeMs = System.currentTimeMillis();
    int deleteStatementCounter = 0;
    // Now delete the rows that appear in previousStats but not in the currentStats
    for (Map.Entry<Long, Map<Short, Map<Short, ContainerStorageStats>>> prevPartitionMapEntry : prevPartitionMap.entrySet()) {
      long partitionId = prevPartitionMapEntry.getKey();
      Map<Short, Map<Short, ContainerStorageStats>> prevAccountMap = prevPartitionMapEntry.getValue();
      Map<Short, Map<Short, ContainerStorageStats>> currAccountMap = currPartitionMap.get(partitionId);
      if (prevAccountMap.size() != 0 && (currAccountMap == null || currAccountMap.size() == 0)) {
        accountReportsDao.deleteStorageUsageForPartition(clusterName, hostname, (int) partitionId);
        deleteStatementCounter++;
        continue;
      }
      if (prevAccountMap.size() != 0 && currAccountMap != null && currAccountMap.size() != 0) {
        for (Map.Entry<Short, Map<Short, ContainerStorageStats>> prevAccountMapEntry : prevAccountMap.entrySet()) {
          short accountId = prevAccountMapEntry.getKey();
          Map<Short, ContainerStorageStats> prevContainerMap = prevAccountMapEntry.getValue();
          Map<Short, ContainerStorageStats> currContainerMap = currAccountMap.get(accountId);
          if (prevContainerMap.size() != 0 && (currContainerMap == null || currContainerMap.size() == 0)) {
            accountReportsDao.deleteStorageUsageForAccount(clusterName, hostname, (int) partitionId, accountId);
            deleteStatementCounter++;
            continue;
          }
          if (prevContainerMap.size() != 0 && currContainerMap != null && currContainerMap.size() != 0) {
            Set<Short> containerIds = new HashSet<Short>(prevContainerMap.keySet());
            containerIds.removeAll(currContainerMap.keySet());
            for (short containerId : containerIds) {
              accountReportsDao.deleteStorageUsageForContainer(clusterName, hostname, (int) partitionId, accountId,
                  containerId);
              deleteStatementCounter++;
            }
          }
        }
      }
    }
    storeMetrics.deleteStatementSize.update(deleteStatementCounter);
    storeMetrics.deleteAccountStatsTimeMs.update(System.currentTimeMillis() - deleteStartTimeMs);
  }
Delete container's accountstats data if partition, or account, or container exists in previous partition map but
missing in current partition map.
@param prevPartitionMap the previous partition stats map.
@param currPartitionMap the current partition stats map.
@throws SQLException
ambry-mysql/src/main/java/com/github/ambry/accountstats/AccountStatsMySqlStore.java