You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2016/09/01 10:13:47 UTC

kylin git commit: KYLIN-1985 SnapshotTable should only keep the columns described in tableDesc

Repository: kylin
Updated Branches:
  refs/heads/master bcd086c11 -> 96da2b6cd


KYLIN-1985 SnapshotTable should only keep the columns described in tableDesc


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

Branch: refs/heads/master
Commit: 96da2b6cd4aa38eca664ebea69f0adc992c58ccd
Parents: bcd086c
Author: Zhengdong <zh...@outlook.com>
Authored: Thu Sep 1 18:11:00 2016 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Thu Sep 1 18:11:31 2016 +0800

----------------------------------------------------------------------
 .../java/org/apache/kylin/dict/lookup/SnapshotTable.java | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/96da2b6c/core-dictionary/src/main/java/org/apache/kylin/dict/lookup/SnapshotTable.java
----------------------------------------------------------------------
diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/lookup/SnapshotTable.java b/core-dictionary/src/main/java/org/apache/kylin/dict/lookup/SnapshotTable.java
index 1aea124..db1a170 100644
--- a/core-dictionary/src/main/java/org/apache/kylin/dict/lookup/SnapshotTable.java
+++ b/core-dictionary/src/main/java/org/apache/kylin/dict/lookup/SnapshotTable.java
@@ -36,6 +36,7 @@ import org.apache.kylin.common.util.Dictionary;
 import org.apache.kylin.dict.StringBytesConverter;
 import org.apache.kylin.dict.TrieDictionary;
 import org.apache.kylin.dict.TrieDictionaryBuilder;
+import org.apache.kylin.metadata.model.ColumnDesc;
 import org.apache.kylin.metadata.model.TableDesc;
 import org.apache.kylin.source.ReadableTable;
 
@@ -84,8 +85,8 @@ public class SnapshotTable extends RootPersistentEntity implements ReadableTable
                 if (row.length <= maxIndex) {
                     throw new IllegalStateException("Bad hive table row, " + tableDesc + " expect " + (maxIndex + 1) + " columns, but got " + Arrays.toString(row));
                 }
-
-                for (String cell : row) {
+                for (ColumnDesc column : tableDesc.getColumns()) {
+                    String cell = row[column.getZeroBasedIndex()];
                     if (cell != null)
                         b.addValue(cell);
                 }
@@ -101,9 +102,9 @@ public class SnapshotTable extends RootPersistentEntity implements ReadableTable
         try {
             while (reader.next()) {
                 String[] row = reader.getRow();
-                int[] rowIndex = new int[row.length];
-                for (int i = 0; i < row.length; i++) {
-                    rowIndex[i] = dict.getIdFromValue(row[i]);
+                int[] rowIndex = new int[tableDesc.getColumnCount()];
+                for (ColumnDesc column : tableDesc.getColumns()) {
+                    rowIndex[column.getZeroBasedIndex()] = dict.getIdFromValue(row[column.getZeroBasedIndex()]);
                 }
                 allRowIndices.add(rowIndex);
             }