@@ -375,7 +375,7 @@ public int resetPostingsScorer(long offset) throws IOException {
375
375
return vectors ;
376
376
}
377
377
378
- float scoreIndividually (int offset ) throws IOException {
378
+ private float scoreIndividually (int offset ) throws IOException {
379
379
float maxScore = Float .NEGATIVE_INFINITY ;
380
380
// score individually, first the quantized byte chunk
381
381
for (int j = 0 ; j < BULK_SIZE ; j ++) {
@@ -419,27 +419,25 @@ float scoreIndividually(int offset) throws IOException {
419
419
return maxScore ;
420
420
}
421
421
422
- private static int filterDocs (int [] docIds , int offset , IntPredicate needsScoring ) {
423
- int filtered = 0 ;
422
+ private static int docToBulkScore (int [] docIds , int offset , IntPredicate needsScoring ) {
423
+ int docToScore = ES91OSQVectorsScorer . BULK_SIZE ;
424
424
for (int i = 0 ; i < ES91OSQVectorsScorer .BULK_SIZE ; i ++) {
425
- if (needsScoring .test (docIds [offset + i ]) == false ) {
426
- docIds [offset + i ] = -1 ;
427
- filtered ++;
425
+ final int idx = offset + i ;
426
+ if (needsScoring .test (docIds [idx ]) == false ) {
427
+ docIds [idx ] = -1 ;
428
+ docToScore --;
428
429
}
429
430
}
430
- return filtered ;
431
+ return docToScore ;
431
432
}
432
433
433
- private static int collect (int [] docIds , int offset , KnnCollector knnCollector , float [] scores ) {
434
- int scoredDocs = 0 ;
434
+ private static void collectBulk (int [] docIds , int offset , KnnCollector knnCollector , float [] scores ) {
435
435
for (int i = 0 ; i < ES91OSQVectorsScorer .BULK_SIZE ; i ++) {
436
- int doc = docIds [offset + i ];
436
+ final int doc = docIds [offset + i ];
437
437
if (doc != -1 ) {
438
- scoredDocs ++;
439
438
knnCollector .collect (doc , scores [i ]);
440
439
}
441
440
}
442
- return scoredDocs ;
443
441
}
444
442
445
443
@ Override
@@ -449,14 +447,14 @@ public int visit(KnnCollector knnCollector) throws IOException {
449
447
int limit = vectors - BULK_SIZE + 1 ;
450
448
int i = 0 ;
451
449
for (; i < limit ; i += BULK_SIZE ) {
452
- int docsToScore = BULK_SIZE - filterDocs (docIdsScratch , i , needsScoring );
453
- if (docsToScore == 0 ) {
450
+ final int docsToBulkScore = docToBulkScore (docIdsScratch , i , needsScoring );
451
+ if (docsToBulkScore == 0 ) {
454
452
continue ;
455
453
}
456
454
quantizeQueryIfNecessary ();
457
455
indexInput .seek (slicePos + i * quantizedByteLength );
458
- float maxScore = Float . NEGATIVE_INFINITY ;
459
- if (docsToScore < BULK_SIZE / 2 ) {
456
+ final float maxScore ;
457
+ if (docsToBulkScore < BULK_SIZE / 2 ) {
460
458
maxScore = scoreIndividually (i );
461
459
} else {
462
460
maxScore = osqVectorsScorer .scoreBulk (
@@ -471,8 +469,9 @@ public int visit(KnnCollector knnCollector) throws IOException {
471
469
);
472
470
}
473
471
if (knnCollector .minCompetitiveSimilarity () < maxScore ) {
474
- scoredDocs += collect (docIdsScratch , i , knnCollector , scores );
472
+ collectBulk (docIdsScratch , i , knnCollector , scores );
475
473
}
474
+ scoredDocs += docsToBulkScore ;
476
475
}
477
476
// process tail
478
477
for (; i < vectors ; i ++) {
0 commit comments