Skip to content

Commit d657f7b

Browse files
authored
Add on_disk_rescore to checkvec tool (elastic#137593)
Found it useful to make this testable :)
1 parent ff45c72 commit d657f7b

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

qa/vector/src/main/java/org/elasticsearch/test/knn/CmdLineArgs.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ record CmdLineArgs(
5858
KnnIndexTester.MergePolicyType mergePolicy,
5959
double writerBufferSizeInMb,
6060
int writerMaxBufferedDocs,
61-
int forceMergeMaxNumSegments
61+
int forceMergeMaxNumSegments,
62+
boolean onDiskRescore
6263
) implements ToXContentObject {
6364

6465
static final ParseField DOC_VECTORS_FIELD = new ParseField("doc_vectors");
@@ -90,6 +91,7 @@ record CmdLineArgs(
9091
static final ParseField MERGE_POLICY_FIELD = new ParseField("merge_policy");
9192
static final ParseField WRITER_BUFFER_MB_FIELD = new ParseField("writer_buffer_mb");
9293
static final ParseField WRITER_BUFFER_DOCS_FIELD = new ParseField("writer_buffer_docs");
94+
static final ParseField ON_DISK_RESCORE_FIELD = new ParseField("on_disk_rescore");
9395

9496
/** By default, in ES the default writer buffer size is 10% of the heap space
9597
* (see {@code IndexingMemoryController.INDEX_BUFFER_SIZE_SETTING}).
@@ -135,6 +137,7 @@ static CmdLineArgs fromXContent(XContentParser parser) throws IOException {
135137
PARSER.declareDouble(Builder::setWriterBufferMb, WRITER_BUFFER_MB_FIELD);
136138
PARSER.declareInt(Builder::setWriterMaxBufferedDocs, WRITER_BUFFER_DOCS_FIELD);
137139
PARSER.declareInt(Builder::setForceMergeMaxNumSegments, FORCE_MERGE_MAX_NUM_SEGMENTS_FIELD);
140+
PARSER.declareBoolean(Builder::setOnDiskRescore, ON_DISK_RESCORE_FIELD);
138141
}
139142

140143
@Override
@@ -209,6 +212,7 @@ static class Builder {
209212
private long seed = 1751900822751L;
210213
private KnnIndexTester.MergePolicyType mergePolicy = null;
211214
private double writerBufferSizeInMb = DEFAULT_WRITER_BUFFER_MB;
215+
private boolean onDiskRescore = false;
212216

213217
/**
214218
* Elasticsearch does not set this explicitly, and in Lucene this setting is
@@ -360,6 +364,11 @@ public Builder setForceMergeMaxNumSegments(int forceMergeMaxNumSegments) {
360364
return this;
361365
}
362366

367+
public Builder setOnDiskRescore(boolean onDiskRescore) {
368+
this.onDiskRescore = onDiskRescore;
369+
return this;
370+
}
371+
363372
public CmdLineArgs build() {
364373
if (docVectors == null) {
365374
throw new IllegalArgumentException("Document vectors path must be provided");
@@ -397,7 +406,8 @@ public CmdLineArgs build() {
397406
mergePolicy,
398407
writerBufferSizeInMb,
399408
writerMaxBufferedDocs,
400-
forceMergeMaxNumSegments
409+
forceMergeMaxNumSegments,
410+
onDiskRescore
401411
);
402412
}
403413
}

qa/vector/src/main/java/org/elasticsearch/test/knn/KnnIndexTester.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ static Codec createCodec(CmdLineArgs args) {
130130
format = new ESNextDiskBBQVectorsFormat(
131131
encoding,
132132
args.ivfClusterSize(),
133-
ES920DiskBBQVectorsFormat.DEFAULT_CENTROIDS_PER_PARENT_CLUSTER
133+
ES920DiskBBQVectorsFormat.DEFAULT_CENTROIDS_PER_PARENT_CLUSTER,
134+
args.onDiskRescore()
134135
);
135136
} else if (args.indexType() == IndexType.GPU_HNSW) {
136137
if (quantizeBits == 32) {

0 commit comments

Comments
 (0)