boolean getIndexEntriesSince(StoreKey key, FindEntriesCondition findEntriesCondition, List<IndexEntry> entries,
      AtomicLong currentTotalSizeOfEntriesInBytes, boolean oneEntryPerKey, boolean inclusive) throws StoreException {
    if (!findEntriesCondition.proceed(currentTotalSizeOfEntriesInBytes.get(), getLastModifiedTimeSecs())) {
      return false;
    }

    // These variables would change with sealed boolean
    NavigableMap<StoreKey, ConcurrentSkipListSet<IndexValue>> indexCopy = index;
    List<IndexEntry> entriesLocal = new ArrayList<>();
    rwLock.readLock().lock();
    boolean isSealed = sealed.get();
    rwLock.readLock().unlock();
    if (isSealed) {
      // the output will be in the entriesLocal.
      sealedIndex.getIndexEntriesSince(key, findEntriesCondition, entriesLocal, currentTotalSizeOfEntriesInBytes,
          inclusive);
    } else if (key == null || indexCopy.containsKey(key)) {
      NavigableMap<StoreKey, ConcurrentSkipListSet<IndexValue>> tempMap = indexCopy;
      if (key != null) {
        tempMap = indexCopy.tailMap(key, inclusive);
      }
      for (Map.Entry<StoreKey, ConcurrentSkipListSet<IndexValue>> entry : tempMap.entrySet()) {
        for (IndexValue value : entry.getValue()) {
          IndexValue newValue = new IndexValue(startOffset.getName(), value.getBytes(), getVersion());
          entriesLocal.add(new IndexEntry(entry.getKey(), newValue));
          currentTotalSizeOfEntriesInBytes.addAndGet(value.getSize());
        }
        // will break if size exceeded only after processing ALL entries for a key
        if (!findEntriesCondition.proceed(currentTotalSizeOfEntriesInBytes.get(), getLastModifiedTimeSecs())) {
          break;
        }
      }
    } else {
      logger.error("IndexSegment : {} key not found: {}", indexFile.getAbsolutePath(), key);
      metrics.keyInFindEntriesAbsent.inc();
    }
    if (oneEntryPerKey) {
      eliminateDuplicates(entriesLocal);
    }
    entries.addAll(entriesLocal);
    return entriesLocal.size() > 0;
  }
Gets all the index entries upto maxEntries from the start of a given key (whether to include this key depends on
inclusive variable) or all entries if key is null, till maxTotalSizeOfEntriesInBytes
@param key The key from where to start retrieving entries.
           If the key is null, all entries are retrieved up to max entries
@param findEntriesCondition The condition that determines when to stop fetching entries.
@param entries The input entries list that needs to be filled. The entries list can have existing entries
@param currentTotalSizeOfEntriesInBytes The current total size in bytes of the entries
@param oneEntryPerKey returns only one index entry per key even if the segment has multiple values for the key.
                      Favors DELETE records over all other records. Favors PUT over a TTL update record.
@param inclusive whether to include entries associated with given key in returned result.
@return true if any entries were added.
@throws StoreException
ambry-store/src/main/java/com/github/ambry/store/IndexSegment.java