From 7ac096b2e0afa14b665a86369c25a2eeaf2966ce Mon Sep 17 00:00:00 2001 From: Naveen Tatikonda Date: Tue, 6 Sep 2022 18:20:02 -0500 Subject: [PATCH] Nomenclature changes from Whitelist to Allowlist (#534) Signed-off-by: Naveen Tatikonda Signed-off-by: Naveen Tatikonda (cherry picked from commit c7379f8a43508a7ebb92a895581a292818b4d3aa) --- ...listExtension.java => KNNAllowlistExtension.java} | 4 ++-- .../opensearch/knn/plugin/script/KNNScoringUtil.java | 12 ++++++------ .../org.opensearch.painless.spi.PainlessExtension | 2 +- .../script/{knn_whitelist.txt => knn_allowlist.txt} | 0 .../knn/plugin/script/KNNScoringUtilTests.java | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) rename src/main/java/org/opensearch/knn/plugin/script/{KNNWhitelistExtension.java => KNNAllowlistExtension.java} (90%) rename src/main/resources/org/opensearch/knn/plugin/script/{knn_whitelist.txt => knn_allowlist.txt} (100%) diff --git a/src/main/java/org/opensearch/knn/plugin/script/KNNWhitelistExtension.java b/src/main/java/org/opensearch/knn/plugin/script/KNNAllowlistExtension.java similarity index 90% rename from src/main/java/org/opensearch/knn/plugin/script/KNNWhitelistExtension.java rename to src/main/java/org/opensearch/knn/plugin/script/KNNAllowlistExtension.java index 4c0fe01a7..959063d61 100644 --- a/src/main/java/org/opensearch/knn/plugin/script/KNNWhitelistExtension.java +++ b/src/main/java/org/opensearch/knn/plugin/script/KNNAllowlistExtension.java @@ -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, List> getContextWhitelists() { diff --git a/src/main/java/org/opensearch/knn/plugin/script/KNNScoringUtil.java b/src/main/java/org/opensearch/knn/plugin/script/KNNScoringUtil.java index 5ec462933..90468c2e7 100644 --- a/src/main/java/org/opensearch/knn/plugin/script/KNNScoringUtil.java +++ b/src/main/java/org/opensearch/knn/plugin/script/KNNScoringUtil.java @@ -65,7 +65,7 @@ private static float[] toFloat(List 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": { @@ -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": { @@ -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": { @@ -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": { @@ -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": { @@ -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": { diff --git a/src/main/resources/META-INF/services/org.opensearch.painless.spi.PainlessExtension b/src/main/resources/META-INF/services/org.opensearch.painless.spi.PainlessExtension index 5fdf5f649..530c96349 100644 --- a/src/main/resources/META-INF/services/org.opensearch.painless.spi.PainlessExtension +++ b/src/main/resources/META-INF/services/org.opensearch.painless.spi.PainlessExtension @@ -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 diff --git a/src/main/resources/org/opensearch/knn/plugin/script/knn_whitelist.txt b/src/main/resources/org/opensearch/knn/plugin/script/knn_allowlist.txt similarity index 100% rename from src/main/resources/org/opensearch/knn/plugin/script/knn_whitelist.txt rename to src/main/resources/org/opensearch/knn/plugin/script/knn_allowlist.txt diff --git a/src/test/java/org/opensearch/knn/plugin/script/KNNScoringUtilTests.java b/src/test/java/org/opensearch/knn/plugin/script/KNNScoringUtilTests.java index 7f66e909a..49add790e 100644 --- a/src/test/java/org/opensearch/knn/plugin/script/KNNScoringUtilTests.java +++ b/src/test/java/org/opensearch/knn/plugin/script/KNNScoringUtilTests.java @@ -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 queryVector = getTestQueryVector(); TestKNNScriptDocValues dataset = new TestKNNScriptDocValues(); dataset.createKNNVectorDocument(new float[] { 4.0f, 4.0f, 4.0f }, "test-index-field-name");