Pair<Long, NavigableMap<LogSegmentName, Long>> getValidSizePerLogSegment(Long deleteReferenceTimeInMS,
      long expiryReferenceTimeInMs) {
    NavigableMap<LogSegmentName, Long> validSizePerLogSegment = new TreeMap<>(logSegmentBaseBucket);
    NavigableMap<Long, NavigableMap<LogSegmentName, Long>> subMap =
        logSegmentDeltaBucketsForDeleted.headMap(deleteReferenceTimeInMS, true);
    for (Map.Entry<Long, NavigableMap<LogSegmentName, Long>> bucket : subMap.entrySet()) {
      for (Map.Entry<LogSegmentName, Long> bucketEntry : bucket.getValue().entrySet()) {
        updateMapHelper(validSizePerLogSegment, bucketEntry.getKey(), bucketEntry.getValue());
      }
    }
    Long lastDeleteReferenceBucketTimeInMs =
        subMap.isEmpty() ? logSegmentForecastStartTimeMsForDeleted : subMap.lastKey();

    subMap = logSegmentDeltaBucketsForExpired.headMap(expiryReferenceTimeInMs, true);
    for (Map.Entry<Long, NavigableMap<LogSegmentName, Long>> bucket : subMap.entrySet()) {
      for (Map.Entry<LogSegmentName, Long> bucketEntry : bucket.getValue().entrySet()) {
        updateMapHelper(validSizePerLogSegment, bucketEntry.getKey(), bucketEntry.getValue());
      }
    }
    return new Pair<>(lastDeleteReferenceBucketTimeInMs, validSizePerLogSegment);
  }
Given a deleted and expired reference time in milliseconds return the corresponding valid data size per log segment
map by aggregating all buckets whose end time is less than or equal to the reference time.
@param deleteReferenceTimeInMS the reference time in ms until which deletes are relevant
@param expiryReferenceTimeInMs the reference time in ms until which expiration is relevant
@return a {@link Pair} whose first element is the end time of the last deleted bucket that was aggregated and whose
second element is the requested valid data size per log segment {@link NavigableMap}.
ambry-store/src/main/java/com/github/ambry/store/ScanResults.java