Skip to content

Commit

Permalink
Remove space type validator class
Browse files Browse the repository at this point in the history
Signed-off-by: John Mazanec <[email protected]>
  • Loading branch information
jmazanec15 committed Jan 18, 2024
1 parent 08e0e51 commit 9101dfa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
14 changes: 0 additions & 14 deletions src/main/java/org/opensearch/knn/index/SpaceType.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
package org.opensearch.knn.index;

import org.apache.lucene.index.VectorSimilarityFunction;
import org.opensearch.common.settings.Setting;

import java.security.InvalidParameterException;
import java.util.HashSet;
import java.util.Set;

Expand Down Expand Up @@ -133,16 +131,4 @@ public static SpaceType getSpace(String spaceTypeName) {
}
throw new IllegalArgumentException("Unable to find space: " + spaceTypeName);
}

// TODO: This can become private once we move space type setting here
public static class SpaceTypeValidator implements Setting.Validator<String> {
@Override
public void validate(String value) {
try {
SpaceType.getSpace(value);
} catch (IllegalArgumentException ex) {
throw new InvalidParameterException(ex.getMessage());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.opensearch.knn.index.util.IndexHyperParametersUtil;
import org.opensearch.knn.index.util.KNNEngine;

import java.security.InvalidParameterException;

import static org.opensearch.common.settings.Setting.Property.Dynamic;
import static org.opensearch.common.settings.Setting.Property.IndexScope;
import static org.opensearch.knn.common.KNNConstants.DIMENSION;
Expand All @@ -42,13 +44,13 @@ public class LegacyFieldMapper extends KNNVectorFieldMapper {
// Settings related to this field mapping type
public static final String KNN_SPACE_TYPE = "index.knn.space_type";
public static final String INDEX_KNN_DEFAULT_SPACE_TYPE = "l2";
public static final Setting<String> INDEX_KNN_SPACE_TYPE = Setting.simpleString(
KNN_SPACE_TYPE,
INDEX_KNN_DEFAULT_SPACE_TYPE,
new SpaceType.SpaceTypeValidator(),
IndexScope,
Setting.Property.Deprecated
);
public static final Setting<String> INDEX_KNN_SPACE_TYPE = Setting.simpleString(KNN_SPACE_TYPE, INDEX_KNN_DEFAULT_SPACE_TYPE, s -> {
try {
SpaceType.getSpace(s);
} catch (IllegalArgumentException ex) {
throw new InvalidParameterException(ex.getMessage());
}
}, IndexScope, Setting.Property.Deprecated);

public static final String KNN_ALGO_PARAM_M = "index.knn.algo_param.m";
public static final Integer INDEX_KNN_DEFAULT_ALGO_PARAM_M = 16;
Expand Down Expand Up @@ -83,9 +85,9 @@ public class LegacyFieldMapper extends KNNVectorFieldMapper {
public static final String KNN_ALGO_PARAM_EF_SEARCH = "index.knn.algo_param.ef_search";
public static final Integer INDEX_KNN_DEFAULT_ALGO_PARAM_EF_SEARCH = 100;
/**
* ef or efSearch - the size of the dynamic list for the nearest neighbors (used during the search).
* Higher ef leads to more accurate but slower search. ef cannot be set lower than the number of queried nearest neighbors k.
* The value ef can be anything between k and the size of the dataset.
* ef or efSearch - the size of the dynamic list for the nearest neighbors (used during the search).
* Higher ef leads to more accurate but slower search. ef cannot be set lower than the number of queried nearest neighbors k.
* The value ef can be anything between k and the size of the dataset.
*/
public static final Setting<Integer> INDEX_KNN_ALGO_PARAM_EF_SEARCH_SETTING = Setting.intSetting(
KNN_ALGO_PARAM_EF_SEARCH,
Expand Down Expand Up @@ -186,7 +188,6 @@ static String getEfConstruction(Settings indexSettings, Version indexVersion) {
}

/**
*
* @param index Name of the index
* @return efSearch value
*/
Expand Down

0 comments on commit 9101dfa

Please sign in to comment.