kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liy...@apache.org
Subject [07/13] kylin git commit: KYLIN-1923 update context columns
Date Mon, 10 Oct 2016 13:56:24 GMT
KYLIN-1923 update context columns

Signed-off-by: Li Yang <liyang@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/20093f47
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/20093f47
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/20093f47

Branch: refs/heads/yang21-cdh5.7
Commit: 20093f47b0d8e1f31a96222c220ef7476d374458
Parents: c553782
Author: Cheng Wang <cheng.wang@kyligence.io>
Authored: Sun Oct 9 17:15:51 2016 +0800
Committer: Li Yang <liyang@apache.org>
Committed: Mon Oct 10 15:32:14 2016 +0800

----------------------------------------------------------------------
 .../relnode/OLAPToEnumerableConverter.java      | 35 +++++++++++++++++---
 1 file changed, 31 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/20093f47/query/src/main/java/org/apache/kylin/query/relnode/OLAPToEnumerableConverter.java
----------------------------------------------------------------------
diff --git a/query/src/main/java/org/apache/kylin/query/relnode/OLAPToEnumerableConverter.java
b/query/src/main/java/org/apache/kylin/query/relnode/OLAPToEnumerableConverter.java
index 95ec617..55c27d3 100644
--- a/query/src/main/java/org/apache/kylin/query/relnode/OLAPToEnumerableConverter.java
+++ b/query/src/main/java/org/apache/kylin/query/relnode/OLAPToEnumerableConverter.java
@@ -19,6 +19,7 @@
 package org.apache.kylin.query.relnode;
 
 import java.util.List;
+import java.util.Set;
 
 import org.apache.calcite.adapter.enumerable.EnumerableRel;
 import org.apache.calcite.adapter.enumerable.EnumerableRelImplementor;
@@ -40,14 +41,18 @@ import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.sql.SqlExplainLevel;
 import org.apache.kylin.common.KylinConfig;
 import org.apache.kylin.common.util.ClassUtil;
+import org.apache.kylin.metadata.filter.ColumnTupleFilter;
 import org.apache.kylin.metadata.filter.LogicalTupleFilter;
 import org.apache.kylin.metadata.filter.TupleFilter;
 import org.apache.kylin.metadata.filter.TupleFilter.FilterOperatorEnum;
+import org.apache.kylin.metadata.model.TblColRef;
 import org.apache.kylin.metadata.realization.IRealization;
 import org.apache.kylin.query.routing.NoRealizationFoundException;
 import org.apache.kylin.query.routing.QueryRouter;
 import org.apache.kylin.query.schema.OLAPTable;
 
+import com.google.common.collect.Sets;
+
 /**
  */
 public class OLAPToEnumerableConverter extends ConverterImpl implements EnumerableRel {
@@ -90,7 +95,11 @@ public class OLAPToEnumerableConverter extends ConverterImpl implements
Enumerab
                 if (null != controllerCls && !controllerCls.isEmpty()) {
                     OLAPContext.IAccessController accessController = (OLAPContext.IAccessController)
ClassUtil.newInstance(controllerCls);
                     TupleFilter tupleFilter = accessController.check(context.olapAuthen,
context.allColumns, context.realization);
-                    context.filter = and(context.filter, tupleFilter);
+                    if (null != tupleFilter) {
+                        context.filterColumns.addAll(collectColumns(tupleFilter));
+                        context.allColumns.addAll(collectColumns(tupleFilter));
+                        context.filter = and(context.filter, tupleFilter);
+                    }
                 }
             }
         } catch (NoRealizationFoundException e) {
@@ -126,23 +135,41 @@ public class OLAPToEnumerableConverter extends ConverterImpl implements
Enumerab
             return f2;
         if (f2 == null)
             return f1;
-        
+
         if (f1.getOperator() == FilterOperatorEnum.AND) {
             f1.addChild(f2);
             return f1;
         }
-        
+
         if (f2.getOperator() == FilterOperatorEnum.AND) {
             f2.addChild(f1);
             return f2;
         }
-        
+
         LogicalTupleFilter and = new LogicalTupleFilter(FilterOperatorEnum.AND);
         and.addChild(f1);
         and.addChild(f2);
         return and;
     }
 
+    private Set<TblColRef> collectColumns(TupleFilter filter) {
+        Set<TblColRef> ret = Sets.newHashSet();
+        collectColumnsRecursively(filter, ret);
+        return ret;
+    }
+
+    private void collectColumnsRecursively(TupleFilter filter, Set<TblColRef> collector)
{
+        if (filter == null)
+            return;
+
+        if (filter instanceof ColumnTupleFilter) {
+            collector.add(((ColumnTupleFilter) filter).getColumn());
+        }
+        for (TupleFilter child : filter.getChildren()) {
+            collectColumnsRecursively(child, collector);
+        }
+    }
+
     private Result buildHiveResult(EnumerableRelImplementor enumImplementor, Prefer pref,
OLAPContext context) {
         RelDataType hiveRowType = getRowType();
 


Mime
View raw message