bbBlock findBlockForRead(Object caller, int version, bbBlock curr, int pos)
    {
        assert pos >= 0 && "buffer positions are never negative".length() > 0;
        if (pos > this._buf_limit) {
            throw new BlockedBufferException("invalid position");
        }
        assert _validate();
        if (curr != null) {
            if (curr.containsForRead(pos)) {
                return curr;
            }
            if (pos == this._buf_limit && (pos - curr._offset) == curr._limit) {
                return curr;
            }
        }
        boolean at_eof = (pos == this._buf_limit);
        if (at_eof) {
            // if this is the last block actually in use
            // and we're looking for the eof position then
            // we can check for the "last byte not quite
            // written yet" case, which is fine
            bbBlock block = this._blocks.get(this._next_block_position - 1);
            if (block.containsForWrite(pos)) return block;
        }
        else {
            bbBlock block = this.findBlockHelper(pos, 0, this._next_block_position);
            return block;
        }
        throw new BlockedBufferException("valid position can't be found!");
    }
bbBlock findBlockForRead ( Object caller , int version , bbBlock curr , int pos ) { assert pos >= 0 && "buffer positions are never negative" . length ( ) > 0 ; if ( pos > this . _buf_limit ) { throw new BlockedBufferException ( "invalid position" ) ; } assert _validate ( ) ; if ( curr != null ) { if ( curr . containsForRead ( pos ) ) { return curr ; } if ( pos == this . _buf_limit && ( pos - curr . _offset ) == curr . _limit ) { return curr ; } } boolean at_eof = ( pos == this . _buf_limit ) ; if ( at_eof ) { bbBlock block = this . _blocks . get ( this . _next_block_position - 1 ) ; if ( block . containsForWrite ( pos ) ) return block ; } else { bbBlock block = this . findBlockHelper ( pos , 0 , this . _next_block_position ) ; return block ; } throw new BlockedBufferException ( "valid position can't be found!" ) ; }
find the block where this offset (newPosition) has already
been written. Typically the caller will set _curr to be the
returned block.
@param pos global position to be read from
@return curr block ready to be read from