Repository: kylin Updated Branches: refs/heads/beforepomupdate 97e67f0de -> d257d73bd
KYLIN-1922 further refinement the check logic Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/d257d73b Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/d257d73b Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/d257d73b Branch: refs/heads/beforepomupdate Commit: d257d73bdd9c1de5cfe4fa1d103eb50a03343bf2 Parents: 97e67f0 Author: Hongbin Ma <mahong...@apache.org> Authored: Thu Jul 28 14:38:39 2016 +0800 Committer: Hongbin Ma <mahong...@apache.org> Committed: Thu Jul 28 14:38:39 2016 +0800 ---------------------------------------------------------------------- .../org/apache/kylin/storage/StorageContext.java | 10 +++++----- .../storage/gtrecord/CubeSegmentScanner.java | 2 +- .../storage/gtrecord/GTCubeStorageQueryBase.java | 18 +++++++++++++----- 3 files changed, 19 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/d257d73b/core-storage/src/main/java/org/apache/kylin/storage/StorageContext.java ---------------------------------------------------------------------- diff --git a/core-storage/src/main/java/org/apache/kylin/storage/StorageContext.java b/core-storage/src/main/java/org/apache/kylin/storage/StorageContext.java index aad37ce..90a2e43 100644 --- a/core-storage/src/main/java/org/apache/kylin/storage/StorageContext.java +++ b/core-storage/src/main/java/org/apache/kylin/storage/StorageContext.java @@ -39,7 +39,7 @@ public class StorageContext { private boolean acceptPartialResult; private boolean exactAggregation; - private boolean groupingByAllCuboidDimensions; + private boolean needStorageAggregation; private boolean enableLimit; private boolean enableCoprocessor; @@ -144,12 +144,12 @@ public class StorageContext { this.partialResultReturned = partialResultReturned; } - public boolean isGroupingByAllCuboidDimensions() { - return groupingByAllCuboidDimensions; + public boolean isNeedStorageAggregation() { + return needStorageAggregation; } - public void setGroupingByAllCuboidDimensions(boolean groupingByAllCuboidDimensions) { - this.groupingByAllCuboidDimensions = groupingByAllCuboidDimensions; + public void setNeedStorageAggregation(boolean needStorageAggregation) { + this.needStorageAggregation = needStorageAggregation; } public void setExactAggregation(boolean isExactAggregation) { http://git-wip-us.apache.org/repos/asf/kylin/blob/d257d73b/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/CubeSegmentScanner.java ---------------------------------------------------------------------- diff --git a/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/CubeSegmentScanner.java b/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/CubeSegmentScanner.java index 21cebc1..cb3bc3b 100644 --- a/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/CubeSegmentScanner.java +++ b/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/CubeSegmentScanner.java @@ -69,7 +69,7 @@ public class CubeSegmentScanner implements IGTScanner { } scanRequest = scanRangePlanner.planScanRequest(); if (scanRequest != null) { - scanRequest.setAllowPreAggregation(!context.isGroupingByAllCuboidDimensions()); + scanRequest.setAllowPreAggregation(!context.isNeedStorageAggregation()); scanRequest.setAggrCacheGB(cubeSeg.getCubeInstance().getConfig().getQueryCoprocessorMemGB()); if (context.isLimitEnabled()) scanRequest.setRowLimit(context.getLimit()); http://git-wip-us.apache.org/repos/asf/kylin/blob/d257d73b/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/GTCubeStorageQueryBase.java ---------------------------------------------------------------------- diff --git a/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/GTCubeStorageQueryBase.java b/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/GTCubeStorageQueryBase.java index d03cfc6..fc145e6 100644 --- a/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/GTCubeStorageQueryBase.java +++ b/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/GTCubeStorageQueryBase.java @@ -20,6 +20,7 @@ package org.apache.kylin.storage.gtrecord; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -100,7 +101,7 @@ public abstract class GTCubeStorageQueryBase implements IStorageQuery { // isExactAggregation? meaning: tuples returned from storage requires no further aggregation in query engine Set<TblColRef> singleValuesD = findSingleValueColumns(filter); context.setExactAggregation(isExactAggregation(cuboid, groups, otherDimsD, singleValuesD, derivedPostAggregation)); - context.setGroupingByAllCuboidDimensions(isGroupingByAllCuboidDimensions(cuboid, groupsD)); + context.setNeedStorageAggregation(isNeedStorageAggregation(cuboid, groupsD, singleValuesD)); // replace derived columns in filter with host columns; columns on loosened condition must be added to group by TupleFilter filterD = translateDerived(filter, groupsD); @@ -221,12 +222,19 @@ public abstract class GTCubeStorageQueryBase implements IStorageQuery { return resultD; } - private boolean isGroupingByAllCuboidDimensions(Cuboid cuboid, Collection<TblColRef> groupD) { - if (cuboid.getColumns().size() != groupD.size()) { + private boolean isNeedStorageAggregation(Cuboid cuboid, Collection<TblColRef> groupD, Collection<TblColRef> singleValueD) { + + logger.info("GroupD :" + groupD); + logger.info("SingleValueD :" + singleValueD); + logger.info("Cuboid columns :" + cuboid.getColumns()); + HashSet<TblColRef> temp = Sets.newHashSet(); + temp.addAll(groupD); + temp.addAll(singleValueD); + if (cuboid.getColumns().size() != temp.size()) { return false; + } else { + return true; } - - return groupD.containsAll(cuboid.getColumns()); } private boolean isExactAggregation(Cuboid cuboid, Collection<TblColRef> groups, Set<TblColRef> othersD, Set<TblColRef> singleValuesD, Set<TblColRef> derivedPostAggregation) {