Source:
private IndexValue findKey(StoreKey key, FileSpan fileSpan, IndexEntryType type) throws StoreException { IndexValue retValue = null; final Timer.Context context = metrics.findTime.time(); try { ConcurrentNavigableMap<Offset, IndexSegment> segmentsMapToSearch; if (fileSpan == null) { logger.trace("Searching for " + key + " in the entire index"); segmentsMapToSearch = indexes.descendingMap(); } else { logger.trace( "Searching for " + key + " in index with filespan ranging from " + fileSpan.getStartOffset() + " to " + fileSpan.getEndOffset()); segmentsMapToSearch = indexes.subMap(indexes.floorKey(fileSpan.getStartOffset()), true, indexes.floorKey(fileSpan.getEndOffset()), true).descendingMap(); metrics.segmentSizeForExists.update(segmentsMapToSearch.size()); } for (Map.Entry<Offset, IndexSegment> entry : segmentsMapToSearch.entrySet()) { logger.trace("Index : searching index with start offset {}", dataDir, entry.getKey()); IndexValue value = entry.getValue().find(key); if (value != null) { logger.trace("Index : found value offset size ttl {}", dataDir, value.getOffset(), value.getSize(), value.getExpiresAtMs()); if (type == null) { retValue = value; break; } else if (type.equals(IndexEntryType.DELETE) && value.isFlagSet(IndexValue.Flags.Delete_Index)) { retValue = value; break; } else if (type.equals(IndexEntryType.PUT) && !value.isFlagSet(IndexValue.Flags.Delete_Index)) { retValue = value; break; } } } } finally { context.stop(); } if (retValue != null) { logger.trace("Index : Returning value offset size ttl {}", dataDir, retValue.getOffset(), retValue.getSize(), retValue.getExpiresAtMs()); } return retValue; }

Target:
private IndexValue findKey(StoreKey key, FileSpan fileSpan, IndexEntryType type) throws StoreException { IndexValue retValue = null; final Timer.Context context = metrics.findTime.time(); try { ConcurrentNavigableMap<Offset, IndexSegment> segmentsMapToSearch; if (fileSpan == null) { logger.trace("Searching for " + key + " in the entire index"); segmentsMapToSearch = indexes.descendingMap(); } else { logger.trace( "Searching for " + key + " in index with filespan ranging from " + fileSpan.getStartOffset() + " to " + fileSpan.getEndOffset()); segmentsMapToSearch = indexes.subMap(indexes.floorKey(fileSpan.getStartOffset()), true, indexes.floorKey(fileSpan.getEndOffset()), true).descendingMap(); metrics.segmentSizeForExists.update(segmentsMapToSearch.size()); } for (Map.Entry<Offset, IndexSegment> entry : segmentsMapToSearch.entrySet()) { logger.trace("Index : searching index with start offset {}", dataDir, entry.getKey()); IndexValue value = entry.getValue().find(key); if (value != null) { logger.trace("Index : found value offset size ttl {}", dataDir, value.getOffset(), value.getSize(), value.getExpiresAtMs()); if (type.equals(IndexEntryType.ANY)) { retValue = value; break; } else if (type.equals(IndexEntryType.DELETE) && value.isFlagSet(IndexValue.Flags.Delete_Index)) { retValue = value; break; } else if (type.equals(IndexEntryType.PUT) && !value.isFlagSet(IndexValue.Flags.Delete_Index)) { retValue = value; break; } } } } finally { context.stop(); } if (retValue != null) { logger.trace("Index : Returning value offset size ttl {}", dataDir, retValue.getOffset(), retValue.getSize(), retValue.getExpiresAtMs()); } return retValue; }