-
Notifications
You must be signed in to change notification settings - Fork 126
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
Generalize lib interface to return context objects #1925
Conversation
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]>
c86d139
to
00002b3
Compare
How about |
@@ -14,7 +14,7 @@ | |||
/** | |||
* Default HNSW context for all engines. Have a different implementation if engine context differs. | |||
*/ | |||
public final class DefaultHnswContext implements EngineSpecificMethodContext { | |||
public final class DefaultHnswContext implements KNNLibrarySearchContext { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe DefaultHnswSearchContext?
@@ -11,7 +11,7 @@ | |||
|
|||
import java.util.Map; | |||
|
|||
public final class DefaultIVFContext implements EngineSpecificMethodContext { | |||
public final class DefaultIVFContext implements KNNLibrarySearchContext { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe DefaultIVFSearchContext?
import org.opensearch.knn.index.engine.Parameter; | ||
import org.opensearch.knn.index.engine.model.QueryContext; | ||
import org.opensearch.knn.index.query.request.MethodParameter; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
public class LuceneHNSWContext implements EngineSpecificMethodContext { | ||
public class LuceneHNSWContext implements KNNLibrarySearchContext { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LuceneHNSWSearchContext
6ce13f2
Addressed @heemin32 ! |
* Simple implementation of {@link KNNLibraryIndexBuildContext} | ||
*/ | ||
@Builder | ||
public class KNNLibraryIndexBuildContextImpl implements KNNLibraryIndexBuildContext { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public class KNNLibraryIndexBuildContextImpl implements KNNLibraryIndexBuildContext { | |
public class KNNLibraryIndexingContextImpl implements KNNLibraryIndexingContext { |
6ce13f2
to
2a696b4
Compare
Signed-off-by: John Mazanec <[email protected]>
2a696b4
to
2149099
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
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]> (cherry picked from commit a16b8aa)
Description
Generalizes the KNNLibrary interface to return an object for both search and indexing so that the plugin can search/index against them. The names of the methods are "getKNNLibraryIndexBuildContext" and "getKNNLibrarySearchContext". In the future, I could see these methods changing into something like getKNNLibraryIndexBuilder and getKNNLibrarySearcher so that the engine actually encapsulates the interactions with the libraries, but that needs some more thought. For now, this change makes it more clear what one of the central roles of the KNNLibrary interface is - telling the plugin how to index/search.
For the quantization framework, making the interface return objects will allow us to properly configure both quantization as well as whatever index we want to use with it. See the following locations for more details where we would do this:
Again, no functionality change - just more refactoring to better support the quantization framework.
One thing I have realized from these changes is that he KNNMethodContext class needs to be sured-up a bit to be more robust. I will create a separate issue for this.
Check List
--signoff
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.