@Override
    public boolean alreadyExists(PersistentIndex idx, FileSpan searchSpan, StoreKey key, IndexValue srcValue)
        throws StoreException {
      IndexValue value = idx.findKey(key, searchSpan, EnumSet.allOf(PersistentIndex.IndexEntryType.class));
      if (value == null) {
        return false;
      }
      if (value.getLifeVersion() > srcValue.getLifeVersion()) {
        // If the IndexValue in the previous index has a lifeVersion higher than source value, then this
        // must be a duplicate.
        return true;
      } else if (value.getLifeVersion() < srcValue.getLifeVersion()) {
        // If the IndexValue in the previous index has a lifeVersion lower than source value, then this
        // is not a duplicate.
        return false;
      } else {
        // When the lifeVersions are the same, the order of the record are **FIX** as
        // P/U -> T -> D
        if (value.isDelete()) {
          return true;
        } else if (value.isTtlUpdate()) {
          // if srcValue is not a delete, it is a duplicate.
          return !srcValue.isDelete();
        } else if (value.isUndelete()) {
          if (srcValue.isPut()) {
            throw new IllegalStateException(
                "An Undelete[" + value + "] and a Put[" + srcValue + "] can't be at the same lifeVersion at store "
                    + dataDir);
          }
          // value is a UNDELETE without a TTL update or
          return srcValue.isUndelete();
        } else {
          if (srcValue.isUndelete()) {
            throw new IllegalStateException(
                "A Put[" + value + "] and an Undelete[" + srcValue + "] can't be at the same lifeVersion at store "
                    + dataDir);
          }
          // value is a PUT without a TTL update
          return srcValue.isPut();
        }
      }
    }
Determines whether a TTL update entry is valid. A TTL update entry is valid as long as the associated PUT record
is still present in the store (the validity of the PUT record does not matter - only its presence/absence does).
@param key the {@link StoreKey} being examined
@param indexSegmentStartOffset the start offset of the {@link IndexSegment} that the TTL update record is in
@return {@code true} if the TTL update entry is valid
@throws StoreException if there are problems reading the index
ambry-store/src/main/java/com/github/ambry/store/BlobStoreCompactor.java