private void eliminateDuplicates(List<IndexEntry> entries) {
    Set<StoreKey> setToFindDuplicate = new HashSet<>();
    // first choose PUTs over update entries (omitting DELETEs and UNDELETEs)
    entries.removeIf(entry -> !entry.getValue().isDelete() && !entry.getValue().isUndelete() && !setToFindDuplicate.add(
        entry.getKey()));
    // then choose DELETEs/UNDELETEs over all other entries
    setToFindDuplicate.clear();
    ListIterator<IndexEntry> iterator = entries.listIterator(entries.size());
    while (iterator.hasPrevious()) {
      IndexEntry entry = iterator.previous();
      if (!setToFindDuplicate.add(entry.getKey())) {
        iterator.remove();
      }
    }
  }
Eliminates duplicates in {@code entries}
@param entries the entries to eliminate duplicates from.
ambry-store/src/main/java/com/github/ambry/store/IndexSegment.java