Correct index path validation (#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.
This commit is contained in:
Benjamin Trent 2025-06-09 09:52:16 -04:00 committed by GitHub
parent e91f9469ae
commit 57ef140d2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 8 deletions

View file

@ -177,14 +177,9 @@ public class KnnIndexTester {
cmdLineArgs.vectorSpace(), cmdLineArgs.vectorSpace(),
cmdLineArgs.numDocs() cmdLineArgs.numDocs()
); );
if (Files.exists(indexPath) == false) { if (cmdLineArgs.reindex() == false && Files.exists(indexPath) == false) {
if (cmdLineArgs.reindex() == false) {
throw new IllegalArgumentException("Index path does not exist: " + indexPath); throw new IllegalArgumentException("Index path does not exist: " + indexPath);
} }
if (cmdLineArgs.forceMerge()) {
throw new IllegalArgumentException("Force merging without an existing index in: " + indexPath);
}
}
if (cmdLineArgs.reindex()) { if (cmdLineArgs.reindex()) {
knnIndexer.createIndex(result); knnIndexer.createIndex(result);
} }

View file

@ -304,7 +304,7 @@ class KnnIndexer {
bytes.position(0); bytes.position(0);
// wrap around back to the start of the file if we hit the end: // wrap around back to the start of the file if we hit the end:
logger.warn("VectorReader hit EOF when reading " + this.input + "; now wrapping around to start of file again"); logger.warn("VectorReader hit EOF when reading " + this.input + "; now wrapping around to start of file again");
this.input.position(position); input.position(position);
bytesRead = Channels.readFromFileChannel(this.input, position, bytes); bytesRead = Channels.readFromFileChannel(this.input, position, bytes);
if (bytesRead < bytes.capacity()) { if (bytesRead < bytes.capacity()) {
throw new IllegalStateException( throw new IllegalStateException(