-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Star tree mapping changes with feature flag --------- Signed-off-by: Bharathwaj G <[email protected]>
- Loading branch information
1 parent
c71fd4a
commit 6267e94
Showing
39 changed files
with
2,951 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
440 changes: 440 additions & 0 deletions
440
server/src/internalClusterTest/java/org/opensearch/index/mapper/StarTreeMapperIT.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
server/src/main/java/org/opensearch/index/compositeindex/CompositeIndexSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( | ||
"star tree index is under an experimental feature and can be activated only by enabling " | ||
+ FeatureFlags.STAR_TREE_INDEX_SETTING.getKey() | ||
+ " 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; | ||
} | ||
|
||
public boolean isStarTreeIndexCreationEnabled() { | ||
return starTreeIndexCreationEnabled; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
server/src/main/java/org/opensearch/index/compositeindex/CompositeIndexValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
|
||
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( | ||
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); | ||
} | ||
} |
Oops, something went wrong.