Source:
private void forwardScan(Offset startOffset, Offset endOffset) throws StoreException { SortedMap<Offset, IndexSegment> tailIndexSegments = index.getIndexSegments().subMap(index.getIndexSegments().floorKey(startOffset), endOffset); int forwardScanEntryCount = 0; for (IndexSegment indexSegment : tailIndexSegments.values()) { if (cancelled) { return; } List<IndexEntry> indexEntries = getIndexEntries(indexSegment); forwardScanEntryCount += indexEntries.size(); for (IndexEntry entry : indexEntries) { IndexValue indexValue = entry.getValue(); if (indexValue.getOffset().compareTo(startOffset) >= 0 && indexValue.getOffset().compareTo(endOffset) < 0) { if (indexValue.isFlagSet(IndexValue.Flags.Delete_Index)) { IndexValue originalPut; if (indexValue.getOriginalMessageOffset() != IndexValue.UNKNOWN_ORIGINAL_MESSAGE_OFFSET && indexValue.getOriginalMessageOffset() >= indexSegment.getStartOffset().getOffset()) { originalPut = getPutRecordForDeletedKey(entry.getKey(), indexValue); if (originalPut.getOffset().compareTo(startOffset) >= 0) { processNewPut(newScanResults, originalPut); } } else { Offset previousIndexSegmentOffset = index.getIndexSegments().size() > 1 ? index.getIndexSegments() .lowerKey(indexSegment.getStartOffset()) : index.getStartOffset(); FileSpan searchSpan = new FileSpan(index.getStartOffset(), previousIndexSegmentOffset); originalPut = index.findKey(entry.getKey(), searchSpan); } if (originalPut != null && !originalPut.isFlagSet(IndexValue.Flags.Delete_Index)) { processNewDelete(newScanResults, indexValue, originalPut); } } else { processNewPut(newScanResults, indexValue); } } } } metrics.statsForwardScanEntryCount.update(forwardScanEntryCount); }

Target:
private void forwardScan(Offset startOffset, Offset endOffset) throws StoreException { SortedMap<Offset, IndexSegment> tailIndexSegments = index.getIndexSegments().subMap(index.getIndexSegments().floorKey(startOffset), endOffset); int forwardScanEntryCount = 0; for (IndexSegment indexSegment : tailIndexSegments.values()) { if (cancelled) { return; } List<IndexEntry> indexEntries = getIndexEntries(indexSegment); forwardScanEntryCount += indexEntries.size(); for (IndexEntry entry : indexEntries) { IndexValue indexValue = entry.getValue(); if (indexValue.getOffset().compareTo(startOffset) >= 0 && indexValue.getOffset().compareTo(endOffset) < 0) { if (indexValue.isFlagSet(IndexValue.Flags.Delete_Index)) { IndexValue originalPut; if (indexValue.getOriginalMessageOffset() == indexValue.getOffset().getOffset()) { originalPut = null; } else if (indexValue.getOriginalMessageOffset() != IndexValue.UNKNOWN_ORIGINAL_MESSAGE_OFFSET && indexValue.getOriginalMessageOffset() >= indexSegment.getStartOffset().getOffset()) { originalPut = getPutRecordForDeletedKey(entry.getKey(), indexValue); if (originalPut.getOffset().compareTo(startOffset) >= 0) { processNewPut(newScanResults, originalPut); } } else { Offset previousIndexSegmentOffset = index.getIndexSegments().size() > 1 ? index.getIndexSegments() .lowerKey(indexSegment.getStartOffset()) : index.getStartOffset(); FileSpan searchSpan = new FileSpan(index.getStartOffset(), previousIndexSegmentOffset); originalPut = index.findKey(entry.getKey(), searchSpan); } if (originalPut == null) { newScanResults.updateLogSegmentBaseBucket(indexValue.getOffset().getName(), indexValue.getSize()); } else if (!originalPut.isFlagSet(IndexValue.Flags.Delete_Index)) { processNewDelete(newScanResults, indexValue, originalPut); } } else { processNewPut(newScanResults, indexValue); } } } } metrics.statsForwardScanEntryCount.update(forwardScanEntryCount); }