Skip to content

Commit

Permalink
Clean up some strings (#190)
Browse files Browse the repository at this point in the history
Signed-off-by: John Mazanec <[email protected]>
  • Loading branch information
jmazanec15 authored Nov 9, 2021
1 parent 7e5abf3 commit 7a9d1e0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/opensearch/knn/common/KNNConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class KNNConstants {
public static final String METHOD_PARAMETER_NPROBES = "nprobes";
public static final String ENCODER_FLAT = "flat";
public static final String ENCODER_PQ = "pq";
public static final String ENCODER_PARAMETER_PQ_CODE_COUNT = "code_count";
public static final String ENCODER_PARAMETER_PQ_M = "m";
public static final String ENCODER_PARAMETER_PQ_CODE_SIZE = "code_size";
public static final String FAISS_HNSW_DESCRIPTION = "HNSW";
public static final String FAISS_IVF_DESCRIPTION = "IVF";
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/opensearch/knn/index/KNNSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ public class KNNSettings {
public static final String KNN_PLUGIN_ENABLED = "knn.plugin.enabled";
public static final String KNN_CIRCUIT_BREAKER_UNSET_PERCENTAGE = "knn.circuit_breaker.unset.percentage";
public static final String KNN_INDEX = "index.knn";
public static final String MODEL_INDEX_NUMBER_OF_SHARDS = "knn.model_index_number_of_shards";
public static final String MODEL_INDEX_NUMBER_OF_REPLICAS = "knn.model_index_number_of_replicas";
public static final String MODEL_CACHE_SIZE_LIMIT = "knn.model_cache.size.limit";
public static final String MODEL_INDEX_NUMBER_OF_SHARDS = "knn.model.index.number_of_shards";
public static final String MODEL_INDEX_NUMBER_OF_REPLICAS = "knn.model.index.number_of_replicas";
public static final String MODEL_CACHE_SIZE_LIMIT = "knn.model.cache.size.limit";

/**
* Default setting values
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/opensearch/knn/index/util/KNNLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import java.util.function.Function;

import static org.opensearch.knn.common.KNNConstants.BYTES_PER_KILOBYTES;
import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_CODE_COUNT;
import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_M;
import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_CODE_COUNT_DEFAULT;
import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_CODE_COUNT_LIMIT;
import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_CODE_SIZE;
Expand Down Expand Up @@ -331,8 +331,8 @@ class Faiss extends NativeLibrary {
MethodAsMapBuilder.builder(KNNConstants.FAISS_FLAT_DESCRIPTION, methodComponent,
methodComponentContext).build())).build(),
KNNConstants.ENCODER_PQ, MethodComponent.Builder.builder(KNNConstants.ENCODER_PQ)
.addParameter(ENCODER_PARAMETER_PQ_CODE_COUNT,
new Parameter.IntegerParameter(ENCODER_PARAMETER_PQ_CODE_COUNT,
.addParameter(ENCODER_PARAMETER_PQ_M,
new Parameter.IntegerParameter(ENCODER_PARAMETER_PQ_M,
ENCODER_PARAMETER_PQ_CODE_COUNT_DEFAULT, v -> v > 0
&& v < ENCODER_PARAMETER_PQ_CODE_COUNT_LIMIT))
.addParameter(ENCODER_PARAMETER_PQ_CODE_SIZE,
Expand All @@ -342,7 +342,7 @@ class Faiss extends NativeLibrary {
.setRequiresTraining(true)
.setMapGenerator(((methodComponent, methodComponentContext) ->
MethodAsMapBuilder.builder(FAISS_PQ_DESCRIPTION, methodComponent, methodComponentContext)
.addParameter(ENCODER_PARAMETER_PQ_CODE_COUNT, "", "")
.addParameter(ENCODER_PARAMETER_PQ_M, "", "")
.addParameter(ENCODER_PARAMETER_PQ_CODE_SIZE, "x", "")
.build()))
.setOverheadInKBEstimator((methodComponent, methodComponentContext, dimension) -> {
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/opensearch/knn/jni/JNIServiceTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.util.List;
import java.util.Map;

import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_CODE_COUNT;
import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_M;
import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_CODE_SIZE;
import static org.opensearch.knn.common.KNNConstants.ENCODER_PQ;
import static org.opensearch.knn.common.KNNConstants.FAISS_NAME;
Expand Down Expand Up @@ -559,7 +559,7 @@ public void testCreateIndexFromTemplate() throws IOException {
METHOD_PARAMETER_NLIST, 16,
METHOD_ENCODER_PARAMETER, new MethodComponentContext(ENCODER_PQ,
ImmutableMap.of(
ENCODER_PARAMETER_PQ_CODE_COUNT, 16,
ENCODER_PARAMETER_PQ_M, 16,
ENCODER_PARAMETER_PQ_CODE_SIZE, 8
)))));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
import java.io.IOException;
import java.util.Map;

import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_CODE_COUNT;
import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_CODE_SIZE;
import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_M;
import static org.opensearch.knn.common.KNNConstants.KNN_ENGINE;
import static org.opensearch.knn.common.KNNConstants.METHOD_ENCODER_PARAMETER;
import static org.opensearch.knn.common.KNNConstants.METHOD_PARAMETER_NLIST;
import static org.opensearch.knn.common.KNNConstants.METHOD_PARAMETER_SPACE_TYPE;
import static org.opensearch.knn.common.KNNConstants.MODEL_ID;
import static org.opensearch.knn.common.KNNConstants.MODEL_STATE;
import static org.opensearch.knn.common.KNNConstants.NAME;
import static org.opensearch.knn.common.KNNConstants.PARAMETERS;

Expand Down Expand Up @@ -237,7 +236,7 @@ public void testTrainModel_success_withId() throws IOException, InterruptedExcep
"name":"pq",
"parameters":{
"code_size":2,
"code_count": 2
"m": 2
}
}
}
Expand All @@ -254,7 +253,7 @@ public void testTrainModel_success_withId() throws IOException, InterruptedExcep
.field(NAME, "pq")
.startObject(PARAMETERS)
.field(ENCODER_PARAMETER_PQ_CODE_SIZE, 2)
.field(ENCODER_PARAMETER_PQ_CODE_COUNT, 2)
.field(ENCODER_PARAMETER_PQ_M, 2)
.endObject()
.endObject()
.endObject()
Expand Down Expand Up @@ -311,7 +310,7 @@ public void testTrainModel_success_noId() throws IOException, InterruptedExcepti
"name":"pq",
"parameters":{
"code_size":2,
"code_count": 2
"m": 2
}
}
}
Expand All @@ -328,7 +327,7 @@ public void testTrainModel_success_noId() throws IOException, InterruptedExcepti
.field(NAME, "pq")
.startObject(PARAMETERS)
.field(ENCODER_PARAMETER_PQ_CODE_SIZE, 2)
.field(ENCODER_PARAMETER_PQ_CODE_COUNT, 2)
.field(ENCODER_PARAMETER_PQ_M, 2)
.endObject()
.endObject()
.endObject()
Expand Down

0 comments on commit 7a9d1e0

Please sign in to comment.