private void addTtlUpdateEntries(Set<MockId> idsToTtlUpdate, IndexSegment segment,
      NavigableMap<MockId, NavigableSet<IndexValue>> referenceIndex) throws StoreException {
    for (MockId id : idsToTtlUpdate) {
      Offset offset = segment.getEndOffset();
      NavigableSet<IndexValue> values = segment.find(id);
      IndexValue value;
      if (values == null) {
        // create an index value with a random log segment name
        value = IndexValueTest.getIndexValue(1, new Offset(StoreTestUtils.getRandomLogSegmentName(null), 0),
            Utils.Infinite_Time, time.milliseconds(), id.getAccountId(), id.getContainerId(), (short) 1, formatVersion);
      } else if (values.last().isDelete()) {
        throw new IllegalArgumentException(id + " is deleted");
      } else if (values.last().isTtlUpdate()) {
        throw new IllegalArgumentException("TTL of " + id + " is already updated");
      } else {
        value = values.last();
      }
      IndexValue newValue = IndexValueTest.getIndexValue(value, formatVersion);
      newValue.setFlag(IndexValue.Flags.Ttl_Update_Index);
      newValue.setExpiresAtMs(Utils.Infinite_Time);
      newValue.setNewOffset(offset);
      newValue.setNewSize(TTL_UPDATE_FILE_SPAN_SIZE);
      segment.addEntry(new IndexEntry(id, newValue),
          new Offset(offset.getName(), offset.getOffset() + TTL_UPDATE_FILE_SPAN_SIZE));
      referenceIndex.computeIfAbsent(id, k -> new TreeSet<>()).add(newValue);
    }
  }
Adds ttl update entries to {@code segment}.
@param idsToTtlUpdate the {@link Set} of IDs to create ttl update entries for.
@param segment the {@link IndexSegment} to add the entries to.
@param referenceIndex the {@link NavigableMap} to add all the entries to. This represents the source of truth for
                      all checks.
@throws StoreException
ambry-store/src/test/java/com/github/ambry/store/IndexSegmentTest.java