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

[Backport 2.x] Nomenclature changes from Whitelist to Allowlist #535

Merged
merged 1 commit into from
Sep 6, 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 @@ -16,9 +16,9 @@
import java.util.List;
import java.util.Map;

public class KNNWhitelistExtension implements PainlessExtension {
public class KNNAllowlistExtension implements PainlessExtension {

private static final Whitelist ALLOW_LIST = WhitelistLoader.loadFromResourceFiles(KNNWhitelistExtension.class, "knn_whitelist.txt");
private static final Whitelist ALLOW_LIST = WhitelistLoader.loadFromResourceFiles(KNNAllowlistExtension.class, "knn_allowlist.txt");

@Override
public Map<ScriptContext<?>, List<Whitelist>> getContextWhitelists() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a plan to change this line as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in my actual PR. The nomenclature changes from whitelist to allowlist are not being supported by opensearch core in 2.x version and are only supported from version 3.0. We are using a couple of opensearch core whitelist packages. We will update these lines of code after we increment our version to 3.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private static float[] toFloat(List<Number> inputVector) {
}

/**
* Whitelisted l2Squared method for users to calculate L2 squared distance between query vector
* Allowlisted l2Squared method for users to calculate L2 squared distance between query vector
* and document vectors
* Example
* "script": {
Expand Down Expand Up @@ -110,7 +110,7 @@ public static float cosinesimilOptimized(float[] queryVector, float[] inputVecto
}

/**
* Whitelisted cosineSimilarity method that can be used in a script to avoid repeated
* Allowlisted cosineSimilarity method that can be used in a script to avoid repeated
* calculation of normalization for the query vector.
* Example:
* "script": {
Expand Down Expand Up @@ -156,7 +156,7 @@ public static float cosinesimil(float[] queryVector, float[] inputVector) {
}

/**
* Whitelisted cosineSimilarity method for users to calculate cosine similarity between query vectors and
* Allowlisted cosineSimilarity method for users to calculate cosine similarity between query vectors and
* document vectors
* Example:
* "script": {
Expand Down Expand Up @@ -216,7 +216,7 @@ public static float l1Norm(float[] queryVector, float[] inputVector) {
}

/**
* Whitelisted l1distance method for users to calculate L1 distance between query vector
* Allowlisted l1distance method for users to calculate L1 distance between query vector
* and document vectors
* Example
* "script": {
Expand Down Expand Up @@ -254,7 +254,7 @@ public static float lInfNorm(float[] queryVector, float[] inputVector) {
}

/**
* Whitelisted lInfNorm method for users to calculate L-inf distance between query vector
* Allowlisted lInfNorm method for users to calculate L-inf distance between query vector
* and document vectors
* Example
* "script": {
Expand Down Expand Up @@ -291,7 +291,7 @@ public static float innerProduct(float[] queryVector, float[] inputVector) {
}

/**
* Whitelisted innerProd method for users to calculate inner product distance between query vector
* Allowlisted innerProd method for users to calculate inner product distance between query vector
* and document vectors
* Example
* "script": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0

org.opensearch.knn.plugin.script.KNNWhitelistExtension
org.opensearch.knn.plugin.script.KNNAllowlistExtension
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void testBitHammingDistance_Long() {
assertEquals(0.0, KNNScoringUtil.calculateHammingBit(long3, long3), 0.1);
}

public void testL2SquaredWhitelistedScoringFunction() throws IOException {
public void testL2SquaredAllowlistedScoringFunction() throws IOException {
List<Number> queryVector = getTestQueryVector();
TestKNNScriptDocValues dataset = new TestKNNScriptDocValues();
dataset.createKNNVectorDocument(new float[] { 4.0f, 4.0f, 4.0f }, "test-index-field-name");
Expand Down