code: public Segment truncate(long index) {
      assertSegmentOpen();
      Assert.index(index >= manager.commitIndex(), "cannot truncate committed index");
  
      long offset = relativeOffset(index);
      long lastOffset = offsetIndex.lastOffset();
  
      long diff = Math.abs(lastOffset - offset);
      skip = Math.max(skip - diff, 0);
  
      if (offset < lastOffset) {
        long position = offsetIndex.truncate(offset);
        buffer.position(position)
          .zero(position)
          .flush();
        termIndex.truncate(offset);
      }
      return this;
    }
docs: Truncates entries after the given index.
  
  @param index The index after which to remove entries.
  @return The segment.
  @throws IllegalStateException if the segment is not open