private void addAllEntriesForKeyInSegment(List<IndexEntry> entries, IndexSegment indexSegment, IndexEntry entry)
        throws StoreException {
      logger.trace("Fetching related entries of a blob with entry {} in index segment with start offset {} in {} "
          + "because they need to be retained", entry, indexSegment.getStartOffset(), storeId);
      NavigableSet<IndexValue> values = indexSegment.find(entry.getKey());
      if (values.size() > 1) {
        // we are using a multivalued index segment. Any related values will be in this set
        values.forEach(valueFromSeg -> entries.add(new IndexEntry(entry.getKey(), valueFromSeg)));
      } else {
        // in a non multi valued segment, there can only be PUTs and DELETEs in the same segment
        entries.add(entry);
        if (entry.getValue().isFlagSet(IndexValue.Flags.Delete_Index)) {
          IndexValue putValue = getPutValueFromDeleteEntry(entry.getKey(), entry.getValue(), indexSegment);
          if (putValue != null) {
            entries.add(new IndexEntry(entry.getKey(), putValue));
          }
        }
      }
    }
Adds entries related to {@code entry} that are in the same {@code indexSegment} including {@code entry}
@param entries the list of {@link IndexEntry} to add to.
@param indexSegment the {@link IndexSegment} to fetch values from.
@param entry the {@link IndexEntry} that is under processing
@throws StoreException if there are problems using the index
ambry-store/src/main/java/com/github/ambry/store/BlobStoreCompactor.java