synchronized JournalSegment<E> getSegment(long index) {
    assertOpen();
    // Check if the current segment contains the given index first in order to prevent an unnecessary map lookup.
    if (currentSegment != null && index > currentSegment.index()) {
      return currentSegment;
    }

    // If the index is in another segment, get the entry with the next lowest first index.
    Map.Entry<Long, JournalSegment<E>> segment = segments.floorEntry(index);
    if (segment != null) {
      return segment.getValue();
    }
    return getFirstSegment();
  }
synchronized JournalSegment < E > getSegment ( long index ) { assertOpen ( ) ; if ( currentSegment != null && index > currentSegment . index ( ) ) { return currentSegment ; } Map . Entry < Long , JournalSegment < E > > segment = segments . floorEntry ( index ) ; if ( segment != null ) { return segment . getValue ( ) ; } return getFirstSegment ( ) ; }
Returns the segment for the given index.

@param index The index for which to return the segment.
@throws IllegalStateException if the segment manager is not open