This is an automated email from the ASF dual-hosted git repository. xxyu pushed a commit to branch kylin5 in repository https://gitbox.apache.org/repos/asf/kylin.git
commit 76d574818f142c81ae4a4a6176222241c36f6578 Author: fanshu.kong <1714585...@qq.com> AuthorDate: Tue Oct 25 16:44:54 2022 +0800 KYLIN-5362 Editing agg-groups doesn't produce extra meaningless indexes from 38573 Co-authored-by: fanshu.kong <1714585...@qq.com> --- .../kylin/metadata/cube/model/RuleBasedIndex.java | 2 +- .../cube/model/RuleBasedCuboidDescTest.java | 25 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/core-metadata/src/main/java/org/apache/kylin/metadata/cube/model/RuleBasedIndex.java b/src/core-metadata/src/main/java/org/apache/kylin/metadata/cube/model/RuleBasedIndex.java index 03c3d128e5..88fe1715a0 100644 --- a/src/core-metadata/src/main/java/org/apache/kylin/metadata/cube/model/RuleBasedIndex.java +++ b/src/core-metadata/src/main/java/org/apache/kylin/metadata/cube/model/RuleBasedIndex.java @@ -528,7 +528,7 @@ public class RuleBasedIndex implements Serializable { private void calculateCurrentSortedList(Map<Integer, Integer> mergedAndSortedIndexMap, List<Integer> currentSortedList, int dimensionId) { boolean needToAppendToTail = true; - Set<Integer> currentSortedSet = Sets.newHashSet(currentSortedList); + Set<Integer> currentSortedSet = Sets.newLinkedHashSet(currentSortedList); if (currentSortedSet.contains(dimensionId)) { return; } diff --git a/src/core-metadata/src/test/java/org/apache/kylin/metadata/cube/model/RuleBasedCuboidDescTest.java b/src/core-metadata/src/test/java/org/apache/kylin/metadata/cube/model/RuleBasedCuboidDescTest.java index 7663330e52..404258a670 100644 --- a/src/core-metadata/src/test/java/org/apache/kylin/metadata/cube/model/RuleBasedCuboidDescTest.java +++ b/src/core-metadata/src/test/java/org/apache/kylin/metadata/cube/model/RuleBasedCuboidDescTest.java @@ -28,6 +28,7 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.kylin.common.KylinConfig; import org.apache.kylin.common.util.JsonUtil; import org.apache.kylin.common.util.NLocalFileMetadataTestCase; +import org.apache.kylin.cube.model.SelectRule; import org.apache.kylin.metadata.cube.CubeTestUtils; import org.apache.kylin.metadata.cube.cuboid.NAggregationGroup; import org.hamcrest.CoreMatchers; @@ -35,6 +36,7 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.springframework.test.util.ReflectionTestUtils; import com.google.common.collect.Lists; import com.google.common.collect.Sets; @@ -908,6 +910,29 @@ public class RuleBasedCuboidDescTest extends NLocalFileMetadataTestCase { }); } + @Test + public void testCalculateDimSortedList() throws Exception { + + NAggregationGroup aggregationGroup1 = new NAggregationGroup(); + aggregationGroup1.setIncludes(new Integer[] { 5, 18 }); + aggregationGroup1.setMeasures(new Integer[] { 10000 }); + SelectRule selectRule1 = new SelectRule(); + selectRule1.setMandatoryDims(new Integer[] {}); + aggregationGroup1.setSelectRule(selectRule1); + + NAggregationGroup aggregationGroup2 = new NAggregationGroup(); + aggregationGroup2.setIncludes(new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 13, 14, 15, 16, 17, 18 }); + aggregationGroup2.setMeasures(new Integer[] { 10000 }); + SelectRule selectRule2 = new SelectRule(); + selectRule2.setMandatoryDims(new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 13, 14, 15, 16, 17, 18 }); + aggregationGroup2.setSelectRule(selectRule2); + + RuleBasedIndex ruleBasedIndex = new RuleBasedIndex(); + List<Integer> lists = ReflectionTestUtils.invokeMethod(ruleBasedIndex, "recomputeSortedDimensions", + Lists.newArrayList(aggregationGroup1, aggregationGroup2)); + Assert.assertEquals("[1, 2, 3, 4, 5, 6, 7, 8, 9, 13, 14, 15, 16, 17, 18]", lists.toString()); + } + private NIndexPlanManager getIndexPlanManager() { return NIndexPlanManager.getInstance(getTestConfig(), "default"); }