public long seekForward ( ) throws IOException { // Try to read the last metadata block interleavedIn . skipToLastAvailableMetaDataBlock ( ) ; if ( ! interleavedIn . readMetaDataIfNeeded ( ) ) { throw new EOFException ( "Cannot get a complete metadata block" ) ; } // Move the interleavedIn to the beginning of a dataSegment SortedMap < Long , Long > offsetPairs = metaData . getOffsetPairs ( ) ; // The last key in the offsetPair points to the farthest position that we can seek to. long uncompressedDataOffset = offsetPairs . lastKey ( ) ; long compressedDataOffset = offsetPairs . get ( uncompressedDataOffset ) ; long toSkip = compressedDataOffset - interleavedIn . getDataOffset ( ) ; if ( toSkip < 0 ) { throw new CorruptedDataException ( "SSF format error: The last offset pair is before the current position in InterleaveStream!" ) ; } try { interleavedIn . skipExactly ( toSkip ) ; } catch ( EOFException e ) { // Ignore this exception // This is the PTail use case. We don't care about this CodecPrematureEOFException } clearDataSegment ( ) ; return uncompressedDataOffset ; }
This function seeks forward using all available bytes . It returns the offset after the seek .