private Offset getLastRecordOffset(LogSegment segment) {
    Offset lastOffset;
    LogSegment nextSegment = state.log.getNextSegment(segment);
    if (nextSegment == null) {
      lastOffset = state.logOrder.lastKey();
    } else {
      Offset nextSegmentStartOffset = new Offset(nextSegment.getName(), nextSegment.getStartOffset());
      lastOffset = state.logOrder.lowerKey(nextSegmentStartOffset);
    }
    return lastOffset;
  }
Gets the offset of the last record in the given log {@code segment}.
@param segment the {@link LogSegment} whose last record offset is required.
@return the offset of the last record in the given log {@code segment}.
ambry-store/src/test/java/com/github/ambry/store/IndexTest.java