You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2016/03/17 11:51:27 UTC

kylin git commit: KYLIN-1492 fix CI

Repository: kylin
Updated Branches:
  refs/heads/master 962958fad -> ad1500186


KYLIN-1492 fix CI


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

Branch: refs/heads/master
Commit: ad15001863abf3687c03af16f736a1eb18cdd4e2
Parents: 962958f
Author: Li Yang <li...@apache.org>
Authored: Thu Mar 17 18:50:55 2016 +0800
Committer: Li Yang <li...@apache.org>
Committed: Thu Mar 17 18:51:19 2016 +0800

----------------------------------------------------------------------
 .../kylin/common/persistence/ResourceTool.java  |  17 +-
 .../org/apache/kylin/cube/kv/CubeDimEncMap.java | 169 ++++++++++---------
 .../rest/service/BadQueryDetectorTest.java      |  15 +-
 3 files changed, 114 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/ad150018/core-common/src/main/java/org/apache/kylin/common/persistence/ResourceTool.java
----------------------------------------------------------------------
diff --git a/core-common/src/main/java/org/apache/kylin/common/persistence/ResourceTool.java b/core-common/src/main/java/org/apache/kylin/common/persistence/ResourceTool.java
index 2e1d527..b11fe1a 100644
--- a/core-common/src/main/java/org/apache/kylin/common/persistence/ResourceTool.java
+++ b/core-common/src/main/java/org/apache/kylin/common/persistence/ResourceTool.java
@@ -124,12 +124,17 @@ public class ResourceTool {
         // case of resource (not a folder)
         if (children == null) {
             if (matchFilter(path)) {
-                RawResource res = src.getResource(path);
-                if (res != null) {
-                    dst.putResource(path, res.inputStream, res.timestamp);
-                    res.inputStream.close();
-                } else {
-                    System.out.println("Resource not exist for " + path);
+                try {
+                    RawResource res = src.getResource(path);
+                    if (res != null) {
+                        dst.putResource(path, res.inputStream, res.timestamp);
+                        res.inputStream.close();
+                    } else {
+                        System.out.println("Resource not exist for " + path);
+                    }
+                } catch (Exception ex) {
+                    System.err.println("Failed to open " + path);
+                    ex.printStackTrace();
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/kylin/blob/ad150018/core-cube/src/main/java/org/apache/kylin/cube/kv/CubeDimEncMap.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/kv/CubeDimEncMap.java b/core-cube/src/main/java/org/apache/kylin/cube/kv/CubeDimEncMap.java
index e3c81f1..e8c5266 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/kv/CubeDimEncMap.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/kv/CubeDimEncMap.java
@@ -1,80 +1,89 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.cube.kv;
-
-import java.util.Map;
-
-import org.apache.kylin.cube.CubeSegment;
-import org.apache.kylin.cube.model.CubeDesc;
-import org.apache.kylin.cube.model.RowKeyColDesc;
-import org.apache.kylin.dimension.Dictionary;
-import org.apache.kylin.dimension.DictionaryDimEnc;
-import org.apache.kylin.dimension.DimensionEncoding;
-import org.apache.kylin.dimension.FixedLenDimEnc;
-import org.apache.kylin.dimension.IDimensionEncodingMap;
-import org.apache.kylin.metadata.model.TblColRef;
-
-import com.google.common.collect.Maps;
-
-public class CubeDimEncMap implements IDimensionEncodingMap {
-
-    final private CubeDesc cubeDesc;
-    final private CubeSegment seg;
-    final private Map<TblColRef, Dictionary<String>> dictionaryMap;
-    final private Map<TblColRef, DimensionEncoding> encMap = Maps.newHashMap();
-    
-    public CubeDimEncMap(CubeSegment seg) {
-        this.cubeDesc = seg.getCubeDesc();
-        this.seg = seg;
-        this.dictionaryMap = null;
-    }
-    
-    public CubeDimEncMap(CubeDesc cubeDesc, Map<TblColRef, Dictionary<String>> dictionaryMap) {
-        this.cubeDesc = cubeDesc;
-        this.seg = null;
-        this.dictionaryMap = dictionaryMap;
-    }
-    
-    @Override
-    public DimensionEncoding get(TblColRef col) {
-        DimensionEncoding result = encMap.get(col);
-        if (result == null) {
-            RowKeyColDesc colDesc = cubeDesc.getRowkey().getColDesc(col);
-            if (colDesc.isUsingDictionary()) {
-                // dictionary encoding
-                result = new DictionaryDimEnc(getDictionary(col));
-            }
-            else {
-                // fixed length encoding
-                result = new FixedLenDimEnc(colDesc.getLength());
-            }
-            encMap.put(col, result);
-        }
-        return result;
-    }
-    
-    @Override
-    public Dictionary<String> getDictionary(TblColRef col) {
-        if (seg == null)
-            return dictionaryMap.get(col);
-        else
-            return seg.getDictionary(col);
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.kylin.cube.kv;
+
+import java.util.Map;
+
+import org.apache.kylin.cube.CubeSegment;
+import org.apache.kylin.cube.model.CubeDesc;
+import org.apache.kylin.cube.model.RowKeyColDesc;
+import org.apache.kylin.dimension.Dictionary;
+import org.apache.kylin.dimension.DictionaryDimEnc;
+import org.apache.kylin.dimension.DimensionEncoding;
+import org.apache.kylin.dimension.FixedLenDimEnc;
+import org.apache.kylin.dimension.IDimensionEncodingMap;
+import org.apache.kylin.metadata.model.TblColRef;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Maps;
+
+public class CubeDimEncMap implements IDimensionEncodingMap {
+
+    private static final Logger logger = LoggerFactory.getLogger(CubeDimEncMap.class);
+
+    final private CubeDesc cubeDesc;
+    final private CubeSegment seg;
+    final private Map<TblColRef, Dictionary<String>> dictionaryMap;
+    final private Map<TblColRef, DimensionEncoding> encMap = Maps.newHashMap();
+
+    public CubeDimEncMap(CubeSegment seg) {
+        this.cubeDesc = seg.getCubeDesc();
+        this.seg = seg;
+        this.dictionaryMap = null;
+    }
+
+    public CubeDimEncMap(CubeDesc cubeDesc, Map<TblColRef, Dictionary<String>> dictionaryMap) {
+        this.cubeDesc = cubeDesc;
+        this.seg = null;
+        this.dictionaryMap = dictionaryMap;
+    }
+
+    @Override
+    public DimensionEncoding get(TblColRef col) {
+        DimensionEncoding result = encMap.get(col);
+        if (result == null) {
+            RowKeyColDesc colDesc = cubeDesc.getRowkey().getColDesc(col);
+            if (colDesc.isUsingDictionary()) {
+                // dictionary encoding
+                Dictionary<String> dict = getDictionary(col);
+                if (dict == null) {
+                    logger.warn("No dictionary found for dict-encoding column " + col + ", segment " + seg);
+                    result = new FixedLenDimEnc(0);
+                } else {
+                    result = new DictionaryDimEnc(dict);
+                }
+            } else {
+                // fixed length encoding
+                result = new FixedLenDimEnc(colDesc.getLength());
+            }
+            encMap.put(col, result);
+        }
+        return result;
+    }
+
+    @Override
+    public Dictionary<String> getDictionary(TblColRef col) {
+        if (seg == null)
+            return dictionaryMap.get(col);
+        else
+            return seg.getDictionary(col);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/kylin/blob/ad150018/server/src/test/java/org/apache/kylin/rest/service/BadQueryDetectorTest.java
----------------------------------------------------------------------
diff --git a/server/src/test/java/org/apache/kylin/rest/service/BadQueryDetectorTest.java b/server/src/test/java/org/apache/kylin/rest/service/BadQueryDetectorTest.java
index e0c7704..3481fa7 100644
--- a/server/src/test/java/org/apache/kylin/rest/service/BadQueryDetectorTest.java
+++ b/server/src/test/java/org/apache/kylin/rest/service/BadQueryDetectorTest.java
@@ -22,11 +22,24 @@ import static org.junit.Assert.*;
 
 import java.util.ArrayList;
 
+import org.apache.kylin.common.util.LocalFileMetadataTestCase;
 import org.apache.kylin.rest.request.SQLRequest;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 
-public class BadQueryDetectorTest {
+public class BadQueryDetectorTest extends LocalFileMetadataTestCase {
 
+    @Before
+    public void before() {
+        super.createTestMetadata();
+    }
+    
+    @After
+    public void after() {
+        super.cleanupTestMetadata();
+    }
+    
     @SuppressWarnings("deprecation")
     @Test
     public void test() throws InterruptedException {