private int getRelativeIndex ( long pos ) { int currentSize = 0 ; currentChunkIndex = 0 ; // loop until we find the chuks holding the given position while ( pos >= ( currentSize += binaryDataChunks . get ( currentChunkIndex ) . length ) ) currentChunkIndex ++ ; currentChunk = binaryDataChunks . get ( currentChunkIndex ) ; currentSize -= currentChunk . length ; // the position referred to the target binary chunk int relativePosition = ( int ) ( pos - currentSize ) ; // the index of the first byte to be returned return relativePosition - 1 ; }
Calculates the index within a binary chunk corresponding to the given absolute position within this BLOB