Skip to content

Commit 1f05dd6

Browse files
committed
iter
1 parent 945bac7 commit 1f05dd6

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

server/src/main/java/org/elasticsearch/index/codec/vectors/DefaultIVFVectorsReader.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,11 @@ public int resetPostingsScorer(long offset) throws IOException {
432432
return vectors;
433433
}
434434

435-
private float scoreIndividually(int offset) throws IOException {
435+
private float scoreIndividually() throws IOException {
436436
float maxScore = Float.NEGATIVE_INFINITY;
437437
// score individually, first the quantized byte chunk
438438
for (int j = 0; j < BULK_SIZE; j++) {
439-
int doc = docIdsScratch[j + offset];
439+
int doc = docIdsScratch[j];
440440
if (doc != -1) {
441441
float qcDist = osqVectorsScorer.quantizeScore(quantizedQueryScratch);
442442
scores[j] = qcDist;
@@ -453,7 +453,7 @@ private float scoreIndividually(int offset) throws IOException {
453453
indexInput.readFloats(correctionsAdd, 0, BULK_SIZE);
454454
// Now apply corrections
455455
for (int j = 0; j < BULK_SIZE; j++) {
456-
int doc = docIdsScratch[offset + j];
456+
int doc = docIdsScratch[j];
457457
if (doc != -1) {
458458
scores[j] = osqVectorsScorer.score(
459459
queryCorrections.lowerInterval(),
@@ -476,22 +476,21 @@ private float scoreIndividually(int offset) throws IOException {
476476
return maxScore;
477477
}
478478

479-
private static int docToBulkScore(int[] docIds, int offset, Bits acceptDocs) {
479+
private static int docToBulkScore(int[] docIds, Bits acceptDocs) {
480480
assert acceptDocs != null : "acceptDocs must not be null";
481481
int docToScore = ES91OSQVectorsScorer.BULK_SIZE;
482482
for (int i = 0; i < ES91OSQVectorsScorer.BULK_SIZE; i++) {
483-
final int idx = offset + i;
484-
if (acceptDocs.get(docIds[idx]) == false) {
485-
docIds[idx] = -1;
483+
if (acceptDocs.get(docIds[i]) == false) {
484+
docIds[i] = -1;
486485
docToScore--;
487486
}
488487
}
489488
return docToScore;
490489
}
491490

492-
private void collectBulk(int offset, KnnCollector knnCollector, float[] scores) {
491+
private void collectBulk(KnnCollector knnCollector, float[] scores) {
493492
for (int i = 0; i < ES91OSQVectorsScorer.BULK_SIZE; i++) {
494-
final int doc = docIdsScratch[offset + i];
493+
final int doc = docIdsScratch[i];
495494
if (doc != -1) {
496495
knnCollector.collect(doc, scores[i]);
497496
}
@@ -518,15 +517,15 @@ public int visit(KnnCollector knnCollector) throws IOException {
518517
for (; i < limit; i += BULK_SIZE) {
519518
// read the doc ids
520519
readDocIds(BULK_SIZE);
521-
final int docsToBulkScore = acceptDocs == null ? BULK_SIZE : docToBulkScore(docIdsScratch, 0, acceptDocs);
520+
final int docsToBulkScore = acceptDocs == null ? BULK_SIZE : docToBulkScore(docIdsScratch, acceptDocs);
522521
if (docsToBulkScore == 0) {
523522
indexInput.skipBytes(quantizedByteLength * BULK_SIZE);
524523
continue;
525524
}
526525
quantizeQueryIfNecessary();
527526
final float maxScore;
528527
if (docsToBulkScore < BULK_SIZE / 2) {
529-
maxScore = scoreIndividually(0);
528+
maxScore = scoreIndividually();
530529
} else {
531530
maxScore = osqVectorsScorer.scoreBulk(
532531
quantizedQueryScratch,
@@ -540,7 +539,7 @@ public int visit(KnnCollector knnCollector) throws IOException {
540539
);
541540
}
542541
if (knnCollector.minCompetitiveSimilarity() < maxScore) {
543-
collectBulk(0, knnCollector, scores);
542+
collectBulk(knnCollector, scores);
544543
}
545544
scoredDocs += docsToBulkScore;
546545
}

0 commit comments

Comments
 (0)