private void flushBlock ( boolean isClose ) throws IOException { if ( isClose ) { if ( ! _isLargeBlob && _offset <= _table . getInlineBlobMax ( ) ) { return ; } } _isLargeBlob = true ; if ( _blobOut == null ) { _blobOut = _table . getTempStore ( ) . openWriter ( ) ; } if ( _offset != _bufferEnd && ! isClose ) { throw new IllegalStateException ( ) ; } _blobOut . write ( _tempBuffer . buffer ( ) , 0 , _offset ) ; _offset = 0 ; if ( ! isClose ) { return ; } StreamSource ss = _blobOut . getStreamSource ( ) ; _blobOut = null ; int len = ( int ) ss . getLength ( ) ; int blobPageSizeMax = _table . getBlobPageSizeMax ( ) ; int pid = - 1 ; int nextPid = - 1 ; int tailLen = len % blobPageSizeMax ; // long seq = 0; PageServiceSync tableService = _table . getTableService ( ) ; if ( tailLen > 0 ) { int tailOffset = len - tailLen ; pid = tableService . writeBlob ( pid , ss . openChild ( ) , tailOffset , tailLen ) ; len -= tailLen ; } while ( len > 0 ) { int sublen = blobPageSizeMax ; int offset = len - blobPageSizeMax ; pid = tableService . writeBlob ( pid , ss . openChild ( ) , offset , sublen ) ; len -= sublen ; } ss . close ( ) ; _blobId = Math . max ( pid , 0 ) ; }
flushes a block of the blob to the temp store if larger than the inline size .