Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move engine and lib components into separate files #438

Merged
merged 5 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,7 @@ public void addKNNBinaryField(FieldInfo field, DocValuesProducer valuesProducer)

KNNEngine knnEngine = model.getModelMetadata().getKnnEngine();

engineFileName = buildEngineFileName(
state.segmentInfo.name,
knnEngine.getLatestBuildVersion(),
field.name,
knnEngine.getExtension()
);
engineFileName = buildEngineFileName(state.segmentInfo.name, knnEngine.getVersion(), field.name, knnEngine.getExtension());
indexPath = Paths.get(((FSDirectory) (FilterDirectory.unwrap(state.directory))).getDirectory().toString(), engineFileName)
.toString();

Expand All @@ -119,12 +114,7 @@ public void addKNNBinaryField(FieldInfo field, DocValuesProducer valuesProducer)
String engineName = field.attributes().getOrDefault(KNNConstants.KNN_ENGINE, KNNEngine.DEFAULT.getName());
KNNEngine knnEngine = KNNEngine.getEngine(engineName);

engineFileName = buildEngineFileName(
state.segmentInfo.name,
knnEngine.getLatestBuildVersion(),
field.name,
knnEngine.getExtension()
);
engineFileName = buildEngineFileName(state.segmentInfo.name, knnEngine.getVersion(), field.name, knnEngine.getExtension());
indexPath = Paths.get(((FSDirectory) (FilterDirectory.unwrap(state.directory))).getDirectory().toString(), engineFileName)
.toString();

Expand Down
327 changes: 327 additions & 0 deletions src/main/java/org/opensearch/knn/index/util/Faiss.java

Large diffs are not rendered by default.

23 changes: 6 additions & 17 deletions src/main/java/org/opensearch/knn/index/util/KNNEngine.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

package org.opensearch.knn.index.util;
Expand Down Expand Up @@ -42,8 +36,8 @@ public enum KNNEngine implements KNNLibrary {
this.knnLibrary = knnLibrary;
}

private String name;
private KNNLibrary knnLibrary;
private final String name;
private final KNNLibrary knnLibrary;

/**
* Get the engine
Expand All @@ -60,7 +54,7 @@ public static KNNEngine getEngine(String name) {
return FAISS;
}

throw new IllegalArgumentException("Invalid engine type: " + name);
throw new IllegalArgumentException(String.format("Invalid engine type: %s", name));
}

/**
Expand Down Expand Up @@ -91,13 +85,8 @@ public String getName() {
}

@Override
public String getLatestBuildVersion() {
return knnLibrary.getLatestBuildVersion();
}

@Override
public String getLatestLibVersion() {
return knnLibrary.getLatestLibVersion();
public String getVersion() {
return knnLibrary.getVersion();
}

@Override
Expand Down
Loading