This is an automated email from the ASF dual-hosted git repository.
Jackie-Jiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 10f87352f1f Scope overwriteTableConfigForTier Table config Jackson to
sub-configs that can hold tier overrides (#18563)
10f87352f1f is described below
commit 10f87352f1feb17cd896b979e1996ed761de48e9
Author: Chaitanya Deepthi <[email protected]>
AuthorDate: Mon May 25 15:51:11 2026 -0700
Scope overwriteTableConfigForTier Table config Jackson to sub-configs that
can hold tier overrides (#18563)
---
.../segment/local/utils/TableConfigUtils.java | 97 +++++++++++++---------
.../segment/local/utils/TableConfigUtilsTest.java | 11 +++
2 files changed, 70 insertions(+), 38 deletions(-)
diff --git
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
index 84d8f7978ff..5f87017a084 100644
---
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
+++
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
@@ -28,7 +28,6 @@ import com.google.common.collect.Sets;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -2156,52 +2155,74 @@ public final class TableConfigUtils {
return tableConfig;
}
try {
- boolean updated = false;
- JsonNode tblCfgJson = tableConfig.toJsonNode();
- // Apply tier specific overwrites for `tableIndexConfig`
- JsonNode tblIdxCfgJson = tblCfgJson.get(TableConfig.INDEXING_CONFIG_KEY);
- if (tblIdxCfgJson != null &&
tblIdxCfgJson.has(TableConfig.TIER_OVERWRITES_KEY)) {
- JsonNode tierCfgJson =
tblIdxCfgJson.get(TableConfig.TIER_OVERWRITES_KEY).get(tier);
- if (tierCfgJson != null) {
- LOGGER.debug("Got table index config overwrites: {} for tier: {}",
tierCfgJson, tier);
- overwriteConfig(tblIdxCfgJson, tierCfgJson);
- updated = true;
- }
- }
- // Apply tier specific overwrites for `fieldConfigList`
- JsonNode fieldCfgListJson =
tblCfgJson.get(TableConfig.FIELD_CONFIG_LIST_KEY);
- if (fieldCfgListJson != null && fieldCfgListJson.isArray()) {
- Iterator<JsonNode> fieldCfgListItr = fieldCfgListJson.elements();
- while (fieldCfgListItr.hasNext()) {
- JsonNode fieldCfgJson = fieldCfgListItr.next();
- if (!fieldCfgJson.has(TableConfig.TIER_OVERWRITES_KEY)) {
- continue;
- }
- JsonNode tierCfgJson =
fieldCfgJson.get(TableConfig.TIER_OVERWRITES_KEY).get(tier);
- if (tierCfgJson != null) {
- LOGGER.debug("Got field index config overwrites: {} for tier: {}",
tierCfgJson, tier);
- overwriteConfig(fieldCfgJson, tierCfgJson);
- updated = true;
- }
- }
- }
- if (updated) {
- LOGGER.debug("Got overwritten table config: {} for tier: {}",
tblCfgJson, tier);
- return JsonUtils.jsonNodeToObject(tblCfgJson, TableConfig.class);
- } else {
- LOGGER.debug("No table config overwrites for tier: {}", tier);
+ IndexingConfig effectiveIndexing =
applyIndexingConfigTierOverride(tableConfig.getIndexingConfig(), tier);
+ List<FieldConfig> effectiveFields =
applyFieldConfigListTierOverrides(tableConfig.getFieldConfigList(), tier);
+ if (effectiveIndexing == tableConfig.getIndexingConfig()
+ && effectiveFields == tableConfig.getFieldConfigList()) {
return tableConfig;
}
+ TableConfig overwritten = new TableConfig(tableConfig);
+ overwritten.setIndexingConfig(effectiveIndexing);
+ overwritten.setFieldConfigList(effectiveFields);
+ return overwritten;
} catch (IOException e) {
LOGGER.warn("Failed to overwrite table config for tier: {} for table:
{}", tier, tableConfig.getTableName(), e);
return tableConfig;
}
}
- private static void overwriteConfig(JsonNode oldCfg, JsonNode newCfg) {
- for (Map.Entry<String, JsonNode> cfgEntry : newCfg.properties()) {
- ((ObjectNode) oldCfg).set(cfgEntry.getKey(), cfgEntry.getValue());
+ private static IndexingConfig applyIndexingConfigTierOverride(IndexingConfig
original, String tier)
+ throws IOException {
+ JsonNode tierOverwrites = original.getTierOverwrites();
+ if (tierOverwrites == null || !tierOverwrites.has(tier)) {
+ return original;
+ }
+ JsonNode override = tierOverwrites.get(tier);
+ if (!override.isObject()) {
+ return original;
+ }
+ ObjectNode merged = (ObjectNode) JsonUtils.objectToJsonNode(original);
+ for (Map.Entry<String, JsonNode> entry : override.properties()) {
+ merged.set(entry.getKey(), entry.getValue());
+ }
+ return JsonUtils.jsonNodeToObject(merged, IndexingConfig.class);
+ }
+
+ @Nullable
+ private static List<FieldConfig> applyFieldConfigListTierOverrides(@Nullable
List<FieldConfig> original, String tier)
+ throws IOException {
+ if (CollectionUtils.isEmpty(original)) {
+ return original;
+ }
+ List<FieldConfig> result = null;
+ for (int i = 0; i < original.size(); i++) {
+ FieldConfig config = original.get(i);
+ FieldConfig effective = applyFieldConfigTierOverride(config, tier);
+ if (effective != config) {
+ if (result == null) {
+ result = new ArrayList<>(original);
+ }
+ result.set(i, effective);
+ }
+ }
+ return result != null ? result : original;
+ }
+
+ private static FieldConfig applyFieldConfigTierOverride(FieldConfig
original, String tier)
+ throws IOException {
+ JsonNode tierOverwrites = original.getTierOverwrites();
+ if (tierOverwrites == null || !tierOverwrites.has(tier)) {
+ return original;
+ }
+ JsonNode override = tierOverwrites.get(tier);
+ if (!override.isObject()) {
+ return original;
+ }
+ ObjectNode merged = (ObjectNode) JsonUtils.objectToJsonNode(original);
+ for (Map.Entry<String, JsonNode> entry : override.properties()) {
+ merged.set(entry.getKey(), entry.getValue());
}
+ return JsonUtils.jsonNodeToObject(merged, FieldConfig.class);
}
/**
diff --git
a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/utils/TableConfigUtilsTest.java
b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/utils/TableConfigUtilsTest.java
index db06da4dabd..e56e1149da9 100644
---
a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/utils/TableConfigUtilsTest.java
+++
b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/utils/TableConfigUtilsTest.java
@@ -3760,6 +3760,17 @@ public class TableConfigUtilsTest {
assertEquals(tierTblCfg, tableConfig);
}
+ @Test
+ public void testOverwriteTableConfigForTierFastPathReturnsSameInstance() {
+ FieldConfig col1 = new FieldConfig.Builder("col1")
+ .withEncodingType(FieldConfig.EncodingType.DICTIONARY)
+ .build();
+ TableConfig tableConfig = new
TableConfigBuilder(TableType.OFFLINE).setTableName(TABLE_NAME)
+ .setFieldConfigList(Collections.singletonList(col1))
+ .build();
+ assertSame(TableConfigUtils.overwriteTableConfigForTier(tableConfig,
"coldTier"), tableConfig);
+ }
+
@Test
public void testGetPartitionColumnWithoutAnyConfig() {
// without instanceAssignmentConfigMap
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]