private WriterFlushResult updateStatePostFlush ( FlushArgs flushArgs ) { // Update the metadata Storage Length. long newLength = this . metadata . getStorageLength ( ) + flushArgs . getLength ( ) ; this . metadata . setStorageLength ( newLength ) ; // Remove operations from the outstanding list as long as every single byte it contains has been committed. boolean reachedEnd = false ; while ( this . operations . size ( ) > 0 && ! reachedEnd ) { StorageOperation first = this . operations . getFirst ( ) ; long lastOffset = first . getLastStreamSegmentOffset ( ) ; reachedEnd = lastOffset >= newLength ; // Verify that if we did reach the 'newLength' offset, we were on an append operation. Anything else is indicative of a bug. assert reachedEnd || isAppendOperation ( first ) : "Flushed operation was not an Append." ; if ( lastOffset <= newLength && isAppendOperation ( first ) ) { this . operations . removeFirst ( ) ; } } // Update the last flush checkpoint. this . lastFlush . set ( this . timer . getElapsed ( ) ) ; return new WriterFlushResult ( ) . withFlushedBytes ( flushArgs . getLength ( ) ) . withFlushedAttributes ( flushArgs . getAttributes ( ) . size ( ) ) ; }
Updates the metadata and the internal state after a flush was completed .