Source:
<code>NavigableSet<IndexValue> find(StoreKey keyToFind) throws StoreException { NavigableSet<IndexValue> toReturn = null; try { rwLock.readLock().lock(); if (!mapped.get()) { NavigableSet<IndexValue> values = index.get(keyToFind); if (values != null) { metrics.blobFoundInActiveSegmentCount.inc(); } toReturn = values; } else { if (bloomFilter != null) { metrics.bloomAccessedCount.inc(); } if (bloomFilter == null || bloomFilter.isPresent(ByteBuffer.wrap(keyToFind.toBytes()))) { if (bloomFilter == null) { logger.trace("IndexSegment bloom filter empty. Searching file with start offset and for key {}", indexFile.getAbsolutePath(), startOffset, keyToFind); } else { metrics.bloomPositiveCount.inc(); logger.trace("IndexSegment found in bloom filter for index with start offset and for key ", indexFile.getAbsolutePath(), startOffset, keyToFind); } ByteBuffer duplicate = mmap.duplicate(); int low = 0; int totalEntries = numberOfEntries(duplicate); int high = totalEntries - 1; logger.trace("binary search low : high : {}", low, high); while (low <= high) { int mid = (int) (Math.ceil(high / 2.0 + low / 2.0)); StoreKey found = getKeyAt(duplicate, mid); logger.trace("Index Segment binary search - key found on iteration {}", indexFile.getAbsolutePath(), found); int result = found.compareTo(keyToFind); if (result == 0) { toReturn = new TreeSet<>(INDEX_VALUE_COMPARATOR); getAllValuesFromMmap(duplicate, keyToFind, mid, totalEntries, toReturn); break; } else if (result < 0) { low = mid + 1; } else { high = mid - 1; } } if (bloomFilter != null && toReturn == null) { metrics.bloomFalsePositiveCount.inc(); } } } } catch (IOException e) { throw new StoreException("IndexSegment : " + indexFile.getAbsolutePath() + " IO error while searching", e, StoreErrorCodes.IOError); } finally { rwLock.readLock().unlock(); } <START> return toReturn; <END> }</code><technical_language>returned set is for read-only purposes, wrap this in a Collections.unmodifiableNavigableSet()</technical_language>

Target:
NavigableSet<IndexValue> find(StoreKey keyToFind) throws StoreException { NavigableSet<IndexValue> toReturn = null; try { rwLock.readLock().lock(); if (!mapped.get()) { ConcurrentSkipListSet<IndexValue> values = index.get(keyToFind); if (values != null) { metrics.blobFoundInActiveSegmentCount.inc(); toReturn = values.clone(); } } else { if (bloomFilter != null) { metrics.bloomAccessedCount.inc(); } if (bloomFilter == null || bloomFilter.isPresent(ByteBuffer.wrap(keyToFind.toBytes()))) { if (bloomFilter == null) { logger.trace("IndexSegment bloom filter empty. Searching file with start offset and for key {}", indexFile.getAbsolutePath(), startOffset, keyToFind); } else { metrics.bloomPositiveCount.inc(); logger.trace("IndexSegment found in bloom filter for index with start offset and for key ", indexFile.getAbsolutePath(), startOffset, keyToFind); } ByteBuffer duplicate = mmap.duplicate(); int low = 0; int totalEntries = numberOfEntries(duplicate); int high = totalEntries - 1; logger.trace("binary search low : high : {}", low, high); while (low <= high) { int mid = (int) (Math.ceil(high / 2.0 + low / 2.0)); StoreKey found = getKeyAt(duplicate, mid); logger.trace("Index Segment binary search - key found on iteration {}", indexFile.getAbsolutePath(), found); int result = found.compareTo(keyToFind); if (result == 0) { toReturn = new TreeSet<>(); getAllValuesFromMmap(duplicate, keyToFind, mid, totalEntries, toReturn); break; } else if (result < 0) { low = mid + 1; } else { high = mid - 1; } } if (bloomFilter != null && toReturn == null) { metrics.bloomFalsePositiveCount.inc(); } } } } catch (IOException e) { throw new StoreException("IndexSegment : " + indexFile.getAbsolutePath() + " IO error while searching", e, StoreErrorCodes.IOError); } finally { rwLock.readLock().unlock(); } return toReturn != null ? Collections.unmodifiableNavigableSet(toReturn) : null; }