This is an automated email from the ASF dual-hosted git repository. nic pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/kylin.git
The following commit(s) were added to refs/heads/master by this push: new 9d6671a KYLIN-4180 Prevent abnormal CPU usage by limiting flat filters length 9d6671a is described below commit 9d6671a024046c121f9f02ff8e9bb51012a12da5 Author: Temple Zhou <dba...@gmail.com> AuthorDate: Thu Sep 26 16:07:01 2019 +0800 KYLIN-4180 Prevent abnormal CPU usage by limiting flat filters length --- .../java/org/apache/kylin/metadata/filter/TupleFilter.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/filter/TupleFilter.java b/core-metadata/src/main/java/org/apache/kylin/metadata/filter/TupleFilter.java index 019960e..6a1d415 100644 --- a/core-metadata/src/main/java/org/apache/kylin/metadata/filter/TupleFilter.java +++ b/core-metadata/src/main/java/org/apache/kylin/metadata/filter/TupleFilter.java @@ -286,6 +286,15 @@ public abstract class TupleFilter { private List<TupleFilter> cartesianProduct(List<TupleFilter> leftOrFilters, TupleFilter partialAndFilter, int maxFlatChildrenSize) { List<TupleFilter> oldProductFilters = new LinkedList<TupleFilter>(); oldProductFilters.add(partialAndFilter); + + int flatChildrenSize = 1; + for (TupleFilter orFilter : leftOrFilters) { + flatChildrenSize *= orFilter.getChildren().size(); + if (flatChildrenSize > maxFlatChildrenSize) { + throw new IllegalStateException("the filter is too large after do the flat, size=" + + flatChildrenSize); + } + } for (TupleFilter orFilter : leftOrFilters) { List<TupleFilter> newProductFilters = new LinkedList<TupleFilter>(); for (TupleFilter orChildFilter : orFilter.getChildren()) { @@ -293,10 +302,6 @@ public abstract class TupleFilter { TupleFilter fullAndFilter = productFilter.copy(); fullAndFilter.addChildren(orChildFilter.getChildren()); newProductFilters.add(fullAndFilter); - if (newProductFilters.size() > maxFlatChildrenSize) { - throw new IllegalStateException("the filter is too large after do the flat, size=" - + newProductFilters.size()); - } } } oldProductFilters = newProductFilters;