Skip to content

Commit 6e3c8d5

Browse files
benwtrentbenchaplin
authored andcommitted
Correct index path validation (elastic#129144)
All we care about is if reindex is true or false. We shouldn't worry about force merge. Because if reindex is true, we will create the directory, if its false, we won't.
1 parent 50d80aa commit 6e3c8d5

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,8 @@ public static void main(String[] args) throws Exception {
177177
cmdLineArgs.vectorSpace(),
178178
cmdLineArgs.numDocs()
179179
);
180-
if (Files.exists(indexPath) == false) {
181-
if (cmdLineArgs.reindex() == false) {
182-
throw new IllegalArgumentException("Index path does not exist: " + indexPath);
183-
}
184-
if (cmdLineArgs.forceMerge()) {
185-
throw new IllegalArgumentException("Force merging without an existing index in: " + indexPath);
186-
}
180+
if (cmdLineArgs.reindex() == false && Files.exists(indexPath) == false) {
181+
throw new IllegalArgumentException("Index path does not exist: " + indexPath);
187182
}
188183
if (cmdLineArgs.reindex()) {
189184
knnIndexer.createIndex(result);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ private void readNext() throws IOException {
304304
bytes.position(0);
305305
// wrap around back to the start of the file if we hit the end:
306306
logger.warn("VectorReader hit EOF when reading " + this.input + "; now wrapping around to start of file again");
307-
this.input.position(position);
307+
input.position(position);
308308
bytesRead = Channels.readFromFileChannel(this.input, position, bytes);
309309
if (bytesRead < bytes.capacity()) {
310310
throw new IllegalStateException(

0 commit comments

Comments
 (0)