-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduces NativeEngineKNNQuery which executes ANN on rewrite
Signed-off-by: Tejas Shah <shatejas@amazon.com>
- Loading branch information
Showing
16 changed files
with
965 additions
and
11 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/main/java/org/opensearch/knn/common/launchcontrol/KNNLaunchControl.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,39 @@ | ||
/* | ||
* 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.common.launchcontrol; | ||
|
||
import org.opensearch.common.settings.Setting; | ||
import org.opensearch.knn.index.KNNSettings; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public final class KNNLaunchControl { | ||
|
||
// Feature flags | ||
public static final String KNN_LAUNCH_QUERY_REWRITE_ENABLED = "knn.launch.query.rewrite.enabled"; | ||
private static final boolean KNN_LAUNCH_QUERY_REWRITE_ENABLED_DEFAULT = true; | ||
|
||
public static Setting<Boolean> KNN_LAUNCH_QUERY_REWRITE_ENABLED_SETTING = Setting.boolSetting( | ||
KNN_LAUNCH_QUERY_REWRITE_ENABLED, | ||
KNN_LAUNCH_QUERY_REWRITE_ENABLED_DEFAULT, | ||
Setting.Property.NodeScope, | ||
Setting.Property.Dynamic | ||
); | ||
|
||
public static Stream<Setting<?>> getFeatureFlags() { | ||
return Stream.of(KNN_LAUNCH_QUERY_REWRITE_ENABLED_SETTING); | ||
} | ||
|
||
public static boolean isFeatureEnabled(final String featureName) { | ||
return Boolean.parseBoolean(KNNSettings.state().getSettingValue(featureName).toString()); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/org/opensearch/knn/common/launchcontrol/LaunchControlUtils.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,26 @@ | ||
/* | ||
* 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.common.launchcontrol; | ||
|
||
import org.apache.lucene.search.Query; | ||
import org.opensearch.knn.index.query.KNNQuery; | ||
import org.opensearch.knn.index.query.nativelib.NativeEngineKnnVectorQuery; | ||
|
||
public final class LaunchControlUtils { | ||
|
||
public static Query getNativeKNNQuery(final KNNQuery knnQuery) { | ||
if (KNNLaunchControl.isFeatureEnabled(KNNLaunchControl.KNN_LAUNCH_QUERY_REWRITE_ENABLED_SETTING.getKey())) { | ||
return new NativeEngineKnnVectorQuery(knnQuery); | ||
} | ||
return knnQuery; | ||
} | ||
} |
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.