private ReadAvailability checkReadAvailability ( long offset , boolean lastOffsetInclusive ) { // We can only read at a particular offset if: // * The offset is not before the Segment's StartOffset // AND // * The segment is not sealed (we are allowed to do a future read) OR // * The segment is sealed and we are not trying to read at or beyond the last offset (based on input). if ( offset < this . metadata . getStartOffset ( ) ) { return ReadAvailability . BeforeStartOffset ; } else if ( this . metadata . isSealed ( ) ) { return offset < ( this . metadata . getLength ( ) + ( lastOffsetInclusive ? 1 : 0 ) ) ? ReadAvailability . Available : ReadAvailability . BeyondLastOffset ; } // Offset is in a valid range. return ReadAvailability . Available ; }
Determines the availability of reading at a particular offset given the state of a segment .