@@ -442,13 +442,13 @@ private float scoreIndividually(int offset) throws IOException {
442442 for (int j = 0 ; j < BULK_SIZE ; j ++) {
443443 int doc = docIdsScratch [j + offset ];
444444 if (doc != -1 ) {
445- indexInput .seek (slicePos + (offset * quantizedByteLength ) + (j * quantizedVectorByteSize ));
446445 float qcDist = osqVectorsScorer .quantizeScore (quantizedQueryScratch );
447446 scores [j ] = qcDist ;
447+ } else {
448+ indexInput .skipBytes (quantizedVectorByteSize );
448449 }
449450 }
450451 // read in all corrections
451- indexInput .seek (slicePos + (offset * quantizedByteLength ) + (BULK_SIZE * quantizedVectorByteSize ));
452452 indexInput .readFloats (correctionsLower , 0 , BULK_SIZE );
453453 indexInput .readFloats (correctionsUpper , 0 , BULK_SIZE );
454454 for (int j = 0 ; j < BULK_SIZE ; j ++) {
@@ -504,18 +504,18 @@ private static void collectBulk(int[] docIds, int offset, KnnCollector knnCollec
504504
505505 @ Override
506506 public int visit (KnnCollector knnCollector ) throws IOException {
507+ indexInput .seek (slicePos );
507508 // block processing
508509 int scoredDocs = 0 ;
509510 int limit = vectors - BULK_SIZE + 1 ;
510511 int i = 0 ;
511-
512512 for (; i < limit ; i += BULK_SIZE ) {
513513 final int docsToBulkScore = acceptDocs == null ? BULK_SIZE : docToBulkScore (docIdsScratch , i , acceptDocs );
514514 if (docsToBulkScore == 0 ) {
515+ indexInput .skipBytes (quantizedByteLength * BULK_SIZE );
515516 continue ;
516517 }
517518 quantizeQueryIfNecessary ();
518- indexInput .seek (slicePos + i * quantizedByteLength );
519519 final float maxScore ;
520520 if (docsToBulkScore < BULK_SIZE / 2 ) {
521521 maxScore = scoreIndividually (i );
@@ -541,7 +541,6 @@ public int visit(KnnCollector knnCollector) throws IOException {
541541 int doc = docIdsScratch [i ];
542542 if (acceptDocs == null || acceptDocs .get (doc )) {
543543 quantizeQueryIfNecessary ();
544- indexInput .seek (slicePos + i * quantizedByteLength );
545544 float qcDist = osqVectorsScorer .quantizeScore (quantizedQueryScratch );
546545 indexInput .readFloats (correctiveValues , 0 , 3 );
547546 final int quantizedComponentSum = Short .toUnsignedInt (indexInput .readShort ());
@@ -560,6 +559,8 @@ public int visit(KnnCollector knnCollector) throws IOException {
560559 );
561560 scoredDocs ++;
562561 knnCollector .collect (doc , score );
562+ } else {
563+ indexInput .skipBytes (quantizedByteLength );
563564 }
564565 }
565566 if (scoredDocs > 0 ) {
0 commit comments