-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
* Star tree mapping changes with feature flag --------- Signed-off-by: Bharathwaj G <[email protected]> (cherry picked from commit 6267e94) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.index.compositeindex; | ||
|
||
import org.opensearch.common.annotation.ExperimentalApi; | ||
import org.opensearch.common.settings.ClusterSettings; | ||
import org.opensearch.common.settings.Setting; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.common.util.FeatureFlags; | ||
|
||
/** | ||
* Cluster level settings for composite indices | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
@ExperimentalApi | ||
public class CompositeIndexSettings { | ||
public static final Setting<Boolean> STAR_TREE_INDEX_ENABLED_SETTING = Setting.boolSetting( | ||
"indices.composite_index.star_tree.enabled", | ||
false, | ||
value -> { | ||
if (FeatureFlags.isEnabled(FeatureFlags.STAR_TREE_INDEX_SETTING) == false && value == true) { | ||
throw new IllegalArgumentException( | ||
Check warning on line 29 in server/src/main/java/org/opensearch/index/compositeindex/CompositeIndexSettings.java Codecov / codecov/patchserver/src/main/java/org/opensearch/index/compositeindex/CompositeIndexSettings.java#L29
|
||
"star tree index is under an experimental feature and can be activated only by enabling " | ||
+ FeatureFlags.STAR_TREE_INDEX_SETTING.getKey() | ||
Check warning on line 31 in server/src/main/java/org/opensearch/index/compositeindex/CompositeIndexSettings.java Codecov / codecov/patchserver/src/main/java/org/opensearch/index/compositeindex/CompositeIndexSettings.java#L31
|
||
+ " feature flag in the JVM options" | ||
); | ||
} | ||
}, | ||
Setting.Property.NodeScope, | ||
Setting.Property.Dynamic | ||
); | ||
|
||
private volatile boolean starTreeIndexCreationEnabled; | ||
|
||
public CompositeIndexSettings(Settings settings, ClusterSettings clusterSettings) { | ||
this.starTreeIndexCreationEnabled = STAR_TREE_INDEX_ENABLED_SETTING.get(settings); | ||
clusterSettings.addSettingsUpdateConsumer(STAR_TREE_INDEX_ENABLED_SETTING, this::starTreeIndexCreationEnabled); | ||
|
||
} | ||
|
||
private void starTreeIndexCreationEnabled(boolean value) { | ||
this.starTreeIndexCreationEnabled = value; | ||
} | ||
Check warning on line 50 in server/src/main/java/org/opensearch/index/compositeindex/CompositeIndexSettings.java Codecov / codecov/patchserver/src/main/java/org/opensearch/index/compositeindex/CompositeIndexSettings.java#L49-L50
|
||
|
||
public boolean isStarTreeIndexCreationEnabled() { | ||
return starTreeIndexCreationEnabled; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.index.compositeindex; | ||
|
||
import org.opensearch.common.annotation.ExperimentalApi; | ||
import org.opensearch.index.IndexSettings; | ||
import org.opensearch.index.compositeindex.datacube.startree.StarTreeValidator; | ||
import org.opensearch.index.mapper.MapperService; | ||
|
||
import java.util.Locale; | ||
|
||
/** | ||
* Validation for composite indices as part of mappings | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
@ExperimentalApi | ||
public class CompositeIndexValidator { | ||
Check warning on line 24 in server/src/main/java/org/opensearch/index/compositeindex/CompositeIndexValidator.java Codecov / codecov/patchserver/src/main/java/org/opensearch/index/compositeindex/CompositeIndexValidator.java#L24
|
||
|
||
public static void validate(MapperService mapperService, CompositeIndexSettings compositeIndexSettings, IndexSettings indexSettings) { | ||
StarTreeValidator.validate(mapperService, compositeIndexSettings, indexSettings); | ||
} | ||
|
||
public static void validate( | ||
MapperService mapperService, | ||
CompositeIndexSettings compositeIndexSettings, | ||
IndexSettings indexSettings, | ||
boolean isCompositeFieldPresent | ||
) { | ||
if (!isCompositeFieldPresent && mapperService.isCompositeIndexPresent()) { | ||
throw new IllegalArgumentException( | ||
String.format( | ||
Check warning on line 38 in server/src/main/java/org/opensearch/index/compositeindex/CompositeIndexValidator.java Codecov / codecov/patchserver/src/main/java/org/opensearch/index/compositeindex/CompositeIndexValidator.java#L37-L38
|
||
Locale.ROOT, | ||
"Composite fields must be specified during index creation, addition of new composite fields during update is not supported" | ||
) | ||
); | ||
} | ||
StarTreeValidator.validate(mapperService, compositeIndexSettings, indexSettings); | ||
} | ||
} |