private BlockedDelta reverseCompute ( ) { int contentSize = getValue ( _next ) . remaining ( ) ; UUID correctChangeId = getChangeId ( _next ) ; int numBlocks = 1 ; if ( _list == null ) { _list = Lists . newArrayListWithCapacity ( 3 ) ; } _list . add ( _next ) ; _oldDelta = _next ; while ( _iterator . hasNext ( ) && getChangeId ( _next = _iterator . next ( ) ) . equals ( correctChangeId ) ) { numBlocks ++ ; _list . add ( _next ) ; contentSize += getValue ( _next ) . remaining ( ) ; _next = null ; } Collections . reverse ( _list ) ; // delta is fragmented if the first block is not zero. In this case, we skip it. if ( getBlock ( _list . get ( 0 ) ) != 0 ) { // We must also clear the list of the fragmented delta blocks to avoid them being stitched in with // the next delta, which will cause a buffer overflow _list . clear ( ) ; return null ; } int expectedBlocks = getNumBlocks ( _list . get ( 0 ) ) ; while ( expectedBlocks != _list . size ( ) ) { contentSize -= getValue ( _list . remove ( _list . size ( ) - 1 ) ) . remaining ( ) ; } return new BlockedDelta ( numBlocks , stitchContent ( contentSize ) ) ; }
stitch delta together in reverse