Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Update default variable settings name #209

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 @@ -84,11 +84,11 @@ public class KNNSettings {
* Default setting values
*/
public static final String INDEX_KNN_DEFAULT_SPACE_TYPE = "l2";
public static final Integer INDEX_KNN_DEFAULT_ALGO_PARAM_M_SETTING = 16;
public static final Integer INDEX_KNN_DEFAULT_ALGO_PARAM_EF_SEARCH_SETTING = 512;
public static final Integer INDEX_KNN_DEFAULT_ALGO_PARAM_EF_CONSTRUCTION_SETTING = 512;
public static final Integer KNN_DEFAULT_ALGO_PARAM_INDEX_THREAD_QTY_SETTING = 1;
public static final Integer KNN_DEFAULT_CIRCUIT_BREAKER_UNSET_PERCENTAGE_SETTING = 75;
public static final Integer INDEX_KNN_DEFAULT_ALGO_PARAM_M = 16;
public static final Integer INDEX_KNN_DEFAULT_ALGO_PARAM_EF_SEARCH = 512;
public static final Integer INDEX_KNN_DEFAULT_ALGO_PARAM_EF_CONSTRUCTION = 512;
public static final Integer KNN_DEFAULT_ALGO_PARAM_INDEX_THREAD_QTY = 1;
public static final Integer KNN_DEFAULT_CIRCUIT_BREAKER_UNSET_PERCENTAGE = 75;

/**
* Settings Definition
Expand All @@ -106,7 +106,7 @@ public class KNNSettings {
* The parameter also determines the algorithm's memory consumption, which is roughly M * 8-10 bytes per stored element.
*/
public static final Setting<Integer> INDEX_KNN_ALGO_PARAM_M_SETTING = Setting.intSetting(KNN_ALGO_PARAM_M,
INDEX_KNN_DEFAULT_ALGO_PARAM_M_SETTING,
INDEX_KNN_DEFAULT_ALGO_PARAM_M,
2,
IndexScope);

Expand All @@ -116,7 +116,7 @@ public class KNNSettings {
* 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,
INDEX_KNN_DEFAULT_ALGO_PARAM_EF_SEARCH_SETTING,
INDEX_KNN_DEFAULT_ALGO_PARAM_EF_SEARCH,
2,
IndexScope,
Dynamic);
Expand All @@ -126,7 +126,7 @@ public class KNNSettings {
* Bigger ef_construction leads to longer construction(more indexing time), but better index quality.
*/
public static final Setting<Integer> INDEX_KNN_ALGO_PARAM_EF_CONSTRUCTION_SETTING = Setting.intSetting(KNN_ALGO_PARAM_EF_CONSTRUCTION,
INDEX_KNN_DEFAULT_ALGO_PARAM_EF_CONSTRUCTION_SETTING,
INDEX_KNN_DEFAULT_ALGO_PARAM_EF_CONSTRUCTION,
2,
IndexScope);

Expand All @@ -144,7 +144,7 @@ public class KNNSettings {
* configure number of threads for graph construction.
*/
public static final Setting<Integer> KNN_ALGO_PARAM_INDEX_THREAD_QTY_SETTING = Setting.intSetting(KNN_ALGO_PARAM_INDEX_THREAD_QTY,
KNN_DEFAULT_ALGO_PARAM_INDEX_THREAD_QTY_SETTING,
KNN_DEFAULT_ALGO_PARAM_INDEX_THREAD_QTY,
1,
INDEX_THREAD_QTY_MAX,
NodeScope,
Expand All @@ -157,7 +157,7 @@ public class KNNSettings {

public static final Setting<Double> KNN_CIRCUIT_BREAKER_UNSET_PERCENTAGE_SETTING = Setting.doubleSetting(
KNN_CIRCUIT_BREAKER_UNSET_PERCENTAGE,
KNN_DEFAULT_CIRCUIT_BREAKER_UNSET_PERCENTAGE_SETTING,
KNN_DEFAULT_CIRCUIT_BREAKER_UNSET_PERCENTAGE,
0,
100,
NodeScope,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
import java.util.List;
import java.util.Map;

import static com.amazon.opendistroforelasticsearch.knn.index.KNNSettings.INDEX_KNN_DEFAULT_ALGO_PARAM_EF_CONSTRUCTION_SETTING;
import static com.amazon.opendistroforelasticsearch.knn.index.KNNSettings.INDEX_KNN_DEFAULT_ALGO_PARAM_M_SETTING;
import static com.amazon.opendistroforelasticsearch.knn.index.KNNSettings.INDEX_KNN_DEFAULT_ALGO_PARAM_EF_CONSTRUCTION;
import static com.amazon.opendistroforelasticsearch.knn.index.KNNSettings.INDEX_KNN_DEFAULT_ALGO_PARAM_M;
import static com.amazon.opendistroforelasticsearch.knn.index.KNNSettings.INDEX_KNN_DEFAULT_SPACE_TYPE;
import static com.amazon.opendistroforelasticsearch.knn.index.KNNSettings.INDEX_KNN_SPACE_TYPE;

Expand Down Expand Up @@ -217,8 +217,8 @@ Builder buildKNNIndexSettings(Builder builder, ParserContext parserContext) {
} catch(IllegalArgumentException ex) {
logger.debug("[KNN] The setting \"" + KNNConstants.HNSW_ALGO_M + "\" was not set for the index. " +
"Likely caused by recent version upgrade. Setting the setting to the default value="
+ INDEX_KNN_DEFAULT_ALGO_PARAM_M_SETTING);
builder.algoParams(KNNConstants.HNSW_ALGO_M, INDEX_KNN_DEFAULT_ALGO_PARAM_M_SETTING);
+ INDEX_KNN_DEFAULT_ALGO_PARAM_M);
builder.algoParams(KNNConstants.HNSW_ALGO_M, INDEX_KNN_DEFAULT_ALGO_PARAM_M);
}

try {
Expand All @@ -227,9 +227,9 @@ Builder buildKNNIndexSettings(Builder builder, ParserContext parserContext) {
} catch(IllegalArgumentException ex) {
logger.debug("[KNN] The setting \"" + KNNConstants.HNSW_ALGO_EF_CONSTRUCTION + "\" was not set for" +
" the index. Likely caused by recent version upgrade. Setting the setting to the default value="
+ INDEX_KNN_DEFAULT_ALGO_PARAM_EF_CONSTRUCTION_SETTING);
+ INDEX_KNN_DEFAULT_ALGO_PARAM_EF_CONSTRUCTION);
builder.algoParams(KNNConstants.HNSW_ALGO_EF_CONSTRUCTION,
INDEX_KNN_DEFAULT_ALGO_PARAM_EF_CONSTRUCTION_SETTING);
INDEX_KNN_DEFAULT_ALGO_PARAM_EF_CONSTRUCTION);
}

return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import org.elasticsearch.index.mapper.Mapper;
import org.elasticsearch.index.mapper.MapperService;

import static com.amazon.opendistroforelasticsearch.knn.index.KNNSettings.INDEX_KNN_DEFAULT_ALGO_PARAM_EF_CONSTRUCTION_SETTING;
import static com.amazon.opendistroforelasticsearch.knn.index.KNNSettings.INDEX_KNN_DEFAULT_ALGO_PARAM_M_SETTING;
import static com.amazon.opendistroforelasticsearch.knn.index.KNNSettings.INDEX_KNN_DEFAULT_ALGO_PARAM_EF_CONSTRUCTION;
import static com.amazon.opendistroforelasticsearch.knn.index.KNNSettings.INDEX_KNN_DEFAULT_ALGO_PARAM_M;
import static com.amazon.opendistroforelasticsearch.knn.index.KNNSettings.INDEX_KNN_DEFAULT_SPACE_TYPE;

import static org.elasticsearch.Version.V_7_1_0;
Expand Down Expand Up @@ -61,10 +61,10 @@ public void testBuildKNNIndexSettings_emptySettings_checkDefaultsSet() {
INDEX_KNN_DEFAULT_SPACE_TYPE);

assertEquals(KNNVectorFieldMapper.Defaults.FIELD_TYPE.getAttributes().get(KNNConstants.HNSW_ALGO_M),
String.valueOf(INDEX_KNN_DEFAULT_ALGO_PARAM_M_SETTING));
String.valueOf(INDEX_KNN_DEFAULT_ALGO_PARAM_M));

assertEquals(KNNVectorFieldMapper.Defaults.FIELD_TYPE.getAttributes().get(
KNNConstants.HNSW_ALGO_EF_CONSTRUCTION), String.valueOf(
INDEX_KNN_DEFAULT_ALGO_PARAM_EF_CONSTRUCTION_SETTING));
INDEX_KNN_DEFAULT_ALGO_PARAM_EF_CONSTRUCTION));
}
}