fix safety check in KnnVectorsWriter

This commit is contained in:
Michael Sokolov 2024-09-28 17:44:33 -04:00
parent f21ec8414c
commit c8eeacb39a
1 changed files with 6 additions and 4 deletions

View File

@ -336,6 +336,7 @@ public abstract class KnnVectorsWriter implements Accountable, Closeable {
index = NO_MORE_DOCS;
} else {
docId = current.mappedDocID;
++lastOrd;
++index;
}
return docId;
@ -355,11 +356,12 @@ public abstract class KnnVectorsWriter implements Accountable, Closeable {
@Override
public float[] vectorValue(int ord) throws IOException {
if (ord != lastOrd + 1) {
if (ord != lastOrd) {
throw new IllegalStateException(
"only supports forward iteration: ord=" + ord + ", lastOrd=" + lastOrd);
} else {
lastOrd = ord;
"only supports forward iteration with a single iterator: ord="
+ ord
+ ", lastOrd="
+ lastOrd);
}
return current.values.vectorValue(current.index());
}