-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generalize lib interface to return context objects (#1925)
Generalizes the KNNLibrary to return an object for both search and indexing so that the plugin can search/index against them. This will help properly pass information that does not need to be sent to the JNI for search and index builds. Signed-off-by: John Mazanec <[email protected]>
- Loading branch information
1 parent
ea8a635
commit a16b8aa
Showing
27 changed files
with
186 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
src/main/java/org/opensearch/knn/index/engine/EngineSpecificMethodContext.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/org/opensearch/knn/index/engine/KNNLibraryIndexingContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.knn.index.engine; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
/** | ||
* Context a library gives to build one of its indices | ||
*/ | ||
public interface KNNLibraryIndexingContext { | ||
/** | ||
* Get map of parameters that get passed to the library to build the index | ||
* | ||
* @return Map of parameters | ||
*/ | ||
Map<String, Object> getLibraryParameters(); | ||
|
||
KNNLibraryIndexingContext EMPTY = Collections::emptyMap; | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/org/opensearch/knn/index/engine/KNNLibraryIndexingContextImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.knn.index.engine; | ||
|
||
import lombok.Builder; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Simple implementation of {@link KNNLibraryIndexingContext} | ||
*/ | ||
@Builder | ||
public class KNNLibraryIndexingContextImpl implements KNNLibraryIndexingContext { | ||
|
||
private Map<String, Object> parameters; | ||
|
||
@Override | ||
public Map<String, Object> getLibraryParameters() { | ||
return parameters; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/org/opensearch/knn/index/engine/KNNLibrarySearchContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.knn.index.engine; | ||
|
||
import org.opensearch.knn.index.engine.model.QueryContext; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
/** | ||
* Holds the context needed to search a knn library. | ||
*/ | ||
public interface KNNLibrarySearchContext { | ||
|
||
/** | ||
* Returns supported parameters for the library. | ||
* | ||
* @param ctx QueryContext | ||
* @return parameters supported by the library | ||
*/ | ||
Map<String, Parameter<?>> supportedMethodParameters(QueryContext ctx); | ||
|
||
KNNLibrarySearchContext EMPTY = ctx -> Collections.emptyMap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.