Source:
private NavigableMap<String, Long> collectValidDataSizeByLogSegment(long referenceTimeInMs) throws StoreException { logger.trace("On demand index scanning to collect compaction data stats wrt ref time " + referenceTimeInMs); long startTimeMs = time.milliseconds(); Map<StoreKey, Long> deletedKeys = new HashMap<>(); NavigableMap<String, Long> validSizePerLogSegment = new TreeMap<>(); int indexSegmentCount = 0; for (IndexSegment indexSegment : index.getIndexSegments().descendingMap().values()) { if (!enabled.get()) { throw new StoreException(String.format("BlobStoreStats is not enabled or closing for store %s", storeId), StoreErrorCodes.Store_Shutting_Down); } long indexSegmentStartProcessTimeMs = time.milliseconds(); List<IndexEntry> validIndexEntries = getValidIndexEntries(indexSegment, getIndexEntries(indexSegment), referenceTimeInMs, deletedKeys); for (IndexEntry indexEntry : validIndexEntries) { updateMapHelper(validSizePerLogSegment, indexSegment.getLogSegmentName(), indexEntry.getValue().getSize()); } metrics.statsOnDemandScanTimePerIndexSegmentMs.update(time.milliseconds() - indexSegmentStartProcessTimeMs, TimeUnit.MILLISECONDS); indexSegmentCount++; if (indexSegmentCount == 1) { logger.info("Completed scanning of 1st index segment by on-demand scanning " + indexSegment); } if (indexSegmentCount % 10 == 0) { logger.info("Completed scanning batch of 10 index segments by on-demand scanning " + indexSegment); } } metrics.statsOnDemandScanTotalTimeMs.update(time.milliseconds() - startTimeMs, TimeUnit.MILLISECONDS); if (validSizePerLogSegment.isEmpty()) { validSizePerLogSegment.put(index.getStartOffset().getName(), 0L); } return validSizePerLogSegment; }

Target:
private NavigableMap<String, Long> collectValidDataSizeByLogSegment(long referenceTimeInMs) throws StoreException { logger.trace("On demand index scanning to collect compaction data stats wrt ref time {}", referenceTimeInMs); long startTimeMs = time.milliseconds(); Map<StoreKey, Long> deletedKeys = new HashMap<>(); NavigableMap<String, Long> validSizePerLogSegment = new TreeMap<>(); int indexSegmentCount = 0; for (IndexSegment indexSegment : index.getIndexSegments().descendingMap().values()) { if (!enabled.get()) { throw new StoreException(String.format("BlobStoreStats is not enabled or closing for store %s", storeId), StoreErrorCodes.Store_Shutting_Down); } long indexSegmentStartProcessTimeMs = time.milliseconds(); List<IndexEntry> validIndexEntries = getValidIndexEntries(indexSegment, getIndexEntries(indexSegment), referenceTimeInMs, deletedKeys); for (IndexEntry indexEntry : validIndexEntries) { updateMapHelper(validSizePerLogSegment, indexSegment.getLogSegmentName(), indexEntry.getValue().getSize()); } metrics.statsOnDemandScanTimePerIndexSegmentMs.update(time.milliseconds() - indexSegmentStartProcessTimeMs, TimeUnit.MILLISECONDS); indexSegmentCount++; if (indexSegmentCount == 1 || indexSegmentCount % 10 == 0) { logger.info("Index segment processing (on-demand scanning) for compaction stats complete for {}", indexSegment); } } metrics.statsOnDemandScanTotalTimeMs.update(time.milliseconds() - startTimeMs, TimeUnit.MILLISECONDS); if (validSizePerLogSegment.isEmpty()) { validSizePerLogSegment.put(index.getStartOffset().getName(), 0L); } return validSizePerLogSegment; }