@@ -565,13 +565,12 @@ void decodeBulk(
565565 ) throws IOException {
566566 int remainingCount = count ;
567567 int nextDoc = firstDoc ;
568+ int blockDocOffset = 0 ;
569+ int blockByteOffset = 0 ;
568570 long [] offsets = new long [count + 1 ];
569- int docsAdded = 0 ;
570- int currBlockByteOffset = 0 ;
571571 List <BytesRef > decompressedBlocks = new ArrayList <>();
572572
573573 while (remainingCount > 0 ) {
574-
575574 long blockId = nextDoc < limitDocNumForBlock ? lastBlockId : findAndUpdateBlock (this .docOffsets , lastBlockId , nextDoc , numBlocks );
576575 assert blockId >= 0 ;
577576
@@ -592,16 +591,15 @@ void decodeBulk(
592591 int startOffset = uncompressedDocStarts [idxFirstDocInBlock ];
593592 int endOffset = uncompressedDocStarts [idxFirstDocInBlock + countInBlock ];
594593 int lenValuesInBlock = endOffset - startOffset ;
595- int offsetIdx = 0 ;
596- for (int i = idxFirstDocInBlock ; i < idxFirstDocInBlock + countInBlock ; i ++) {
597- offsets [docsAdded + offsetIdx +1 ] = uncompressedDocStarts [i +1 ] - startOffset + currBlockByteOffset ;
598- offsetIdx ++;
594+ for (int i = 0 ; i < countInBlock ; i ++) {
595+ int byteOffsetInBlock = uncompressedDocStarts [idxFirstDocInBlock + i + 1 ] - startOffset ;
596+ offsets [blockDocOffset + i + 1 ] = byteOffsetInBlock + blockByteOffset ;
599597 }
600598
601599 nextDoc += countInBlock ;
602600 remainingCount -= countInBlock ;
603- docsAdded += countInBlock ;
604- currBlockByteOffset += lenValuesInBlock ;
601+ blockDocOffset += countInBlock ;
602+ blockByteOffset += lenValuesInBlock ;
605603
606604 if (remainingCount == 0 ) {
607605 // avoid making a copy if this was the last block to be decompressed
0 commit comments