kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liy...@apache.org
Subject [2/7] kylin git commit: KYLIN-1728 Introduce dictionary metadata
Date Sun, 05 Jun 2016 01:12:59 GMT
KYLIN-1728 Introduce dictionary metadata


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

Branch: refs/heads/KYLIN-1705-CI
Commit: 59aaeb3057442dbf621aeefc634db1ae1060daff
Parents: ff36ab7
Author: sunyerui <sunyerui@gmail.com>
Authored: Fri May 27 01:27:01 2016 +0800
Committer: Yang Li <liyang@apache.org>
Committed: Sun Jun 5 08:25:49 2016 +0800

----------------------------------------------------------------------
 .../java/org/apache/kylin/cube/CubeSegment.java |  3 +-
 .../org/apache/kylin/cube/model/CubeDesc.java   | 30 ++++++++++++++++++--
 .../cube/model/CubeJoinedFlatTableDesc.java     | 19 +++++++++++++
 3 files changed, 48 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/59aaeb30/core-cube/src/main/java/org/apache/kylin/cube/CubeSegment.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/CubeSegment.java b/core-cube/src/main/java/org/apache/kylin/cube/CubeSegment.java
index a030b92..cbcee14 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/CubeSegment.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/CubeSegment.java
@@ -303,7 +303,8 @@ public class CubeSegment implements Comparable<CubeSegment>, IRealizationSegment
     }
 
     public Dictionary<String> getDictionary(TblColRef col) {
-        return CubeManager.getInstance(this.getCubeInstance().getConfig()).getDictionary(this,
col);
+        TblColRef reuseCol = getCubeDesc().getDictionaryReuseColumn(col);
+        return CubeManager.getInstance(this.getCubeInstance().getConfig()).getDictionary(this,
reuseCol);
     }
 
     public CubeDimEncMap getDimensionEncodingMap() {

http://git-wip-us.apache.org/repos/asf/kylin/blob/59aaeb30/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java b/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
index 5b72b7e..fec385f 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
@@ -918,6 +918,10 @@ public class CubeDesc extends RootPersistentEntity {
         if (dictionaries != null) {
             for (DictionaryDesc dictDesc : dictionaries) {
                 dictDesc.init(this);
+                allColumns.add(dictDesc.getColumnRef());
+                if (dictDesc.getResuseColumnRef() != null) {
+                    allColumns.add(dictDesc.getResuseColumnRef());
+                }
             }
         }
     }
@@ -1057,13 +1061,28 @@ public class CubeDesc extends RootPersistentEntity {
         // remove columns that reuse other's dictionary
         if (dictionaries != null) {
             for (DictionaryDesc dictDesc : dictionaries) {
-                if (dictDesc.getResuseColumnRef() != null)
+                if (dictDesc.getResuseColumnRef() != null) {
                     result.remove(dictDesc.getColumnRef());
+                    result.add(dictDesc.getResuseColumnRef());
+                }
             }
         }
         
         return result;
     }
+
+    /** A column may reuse dictionary of another column, find the dict column, return same
col if there's no reuse column*/
+    public TblColRef getDictionaryReuseColumn(TblColRef col) {
+        if (dictionaries == null) {
+            return col;
+        }
+        for (DictionaryDesc dictDesc : dictionaries) {
+            if (dictDesc.getColumnRef().equals(col) && dictDesc.getResuseColumnRef()
!= null) {
+                return dictDesc.getResuseColumnRef();
+            }
+        }
+        return col;
+    }
     
     /** Get a column which can be used in distributing the source table */
     public TblColRef getDistributedByColumn() {
@@ -1080,8 +1099,13 @@ public class CubeDesc extends RootPersistentEntity {
             return null;
         
         for (DictionaryDesc desc : dictionaries) {
-            if (col.equals(desc.getColumnRef()) && desc.getBuilderClass() != null)
-                return desc.getBuilderClass();
+            if (desc.getBuilderClass() != null) {
+                if (col.equals(desc.getResuseColumnRef())) {
+                    return desc.getBuilderClass();
+                } else if (col.equals(desc.getColumnRef())) {
+                    return desc.getBuilderClass();
+                }
+            }
         }
         return null;
     }

http://git-wip-us.apache.org/repos/asf/kylin/blob/59aaeb30/core-cube/src/main/java/org/apache/kylin/cube/model/CubeJoinedFlatTableDesc.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/model/CubeJoinedFlatTableDesc.java
b/core-cube/src/main/java/org/apache/kylin/cube/model/CubeJoinedFlatTableDesc.java
index 9adac62..a1d468a 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/model/CubeJoinedFlatTableDesc.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/model/CubeJoinedFlatTableDesc.java
@@ -118,6 +118,25 @@ public class CubeJoinedFlatTableDesc implements IJoinedFlatTableDesc
{
             }
         }
 
+        if (cubeDesc.getDictionaries() != null) {
+            for (DictionaryDesc dictDesc : cubeDesc.getDictionaries()) {
+                TblColRef c = dictDesc.getColumnRef();
+                if (contains(columnList, c) < 0) {
+                    columnIndexMap.put(colName(c.getCanonicalName()), columnIndex);
+                    columnList.add(new IntermediateColumnDesc(String.valueOf(columnIndex),
c));
+                    columnIndex++;
+                }
+                if (dictDesc.getResuseColumnRef() != null) {
+                    c = dictDesc.getResuseColumnRef();
+                    if (contains(columnList, c) < 0) {
+                        columnIndexMap.put(colName(c.getCanonicalName()), columnIndex);
+                        columnList.add(new IntermediateColumnDesc(String.valueOf(columnIndex),
c));
+                        columnIndex++;
+                    }
+                }
+            }
+        }
+
         columnCount = columnIndex;
     }
 


Mime
View raw message