code: public long term(long index) {
      assertSegmentOpen();
      checkRange(index);
  
      // Get the offset of the index within this segment.
      long offset = relativeOffset(index);
  
      // Look up the term for the offset in the term index.
      return termIndex.lookup(offset);
    }
docs: Reads the term for the entry at the given index.
  
  @param index The index for which to read the term.
  @return The term for the given index.
  @throws IllegalStateException if the segment is not open or {@code index} is inconsistent