kylin-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] shaofengshi closed pull request #168: Kylin 3255 cannot save cube
Date Wed, 18 Jul 2018 14:23:09 GMT
shaofengshi closed pull request #168: Kylin 3255 cannot save cube
URL: https://github.com/apache/kylin/pull/168
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core-cube/src/main/java/org/apache/kylin/cube/CubeDescManager.java b/core-cube/src/main/java/org/apache/kylin/cube/CubeDescManager.java
index db422632c1..4fb9522c96 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/CubeDescManager.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/CubeDescManager.java
@@ -276,13 +276,11 @@ private void postProcessCubeDesc(CubeDesc cubeDesc) {
                     String encoding = configuration.get(TopNMeasureType.CONFIG_ENCODING_PREFIX
+ parameter.getValue());
                     String encodingVersionStr = configuration
                             .get(TopNMeasureType.CONFIG_ENCODING_VERSION_PREFIX + parameter.getValue());
-                    if (StringUtils.isEmpty(encoding) || encoding.startsWith("dict")) {
-                        if (DictionaryDimEnc.ENCODING_NAME.equals(encoding)) {
-                            keyLength += DictionaryDimEnc.MAX_ENCODING_LENGTH; // estimation
for dict encoding
-                        } else {
-                            throw new IllegalArgumentException(
-                                    "TOP_N's Encoding is " + encoding + ", please choose
the correct one");
-                        }
+                    if (StringUtils.isEmpty(encoding) || DictionaryDimEnc.ENCODING_NAME.equals(encoding))
{
+                        keyLength += DictionaryDimEnc.MAX_ENCODING_LENGTH; // estimation
for dict encoding
+                    } else if (encoding.startsWith("dict")) {
+                        throw new IllegalArgumentException(
+                                "TOP_N's Encoding is " + encoding + ", please choose the
correct one");
                     } else {
                         // non-dict encoding
                         int encodingVersion = 1;
diff --git a/core-cube/src/test/java/org/apache/kylin/cube/CubeDescManagerTest.java b/core-cube/src/test/java/org/apache/kylin/cube/CubeDescManagerTest.java
new file mode 100644
index 0000000000..01336bcebe
--- /dev/null
+++ b/core-cube/src/test/java/org/apache/kylin/cube/CubeDescManagerTest.java
@@ -0,0 +1,78 @@
+/*
+ * 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;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.kylin.dimension.DictionaryDimEnc;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class CubeDescManagerTest {
+
+    @Test
+    public void testNullProcessLogic() throws Exception {
+        String encoding = null;
+        if (StringUtils.isEmpty(encoding) || DictionaryDimEnc.ENCODING_NAME.equals(encoding))
{
+            assertEquals(null, encoding);
+        } else if (encoding.startsWith("dict")) {
+            assertFalse(encoding.startsWith("dict"));
+        } else {
+            assertEquals("dict", encoding);
+        }
+    }
+
+    @Test
+    public void testDictProcessLogic() throws Exception {
+        String encoding = "dict";
+        if (StringUtils.isEmpty(encoding) || DictionaryDimEnc.ENCODING_NAME.equals(encoding))
{
+            assertEquals("dict", encoding);
+        } else if (encoding.startsWith("dict")) {
+            assertFalse(encoding.startsWith("dict"));
+        } else {
+            assertEquals("dict", encoding);
+        }
+    }
+
+    @Test
+    public void testStartDictProcessLogic() throws Exception {
+        String encoding = "dict(v1)";
+        if (StringUtils.isEmpty(encoding) || DictionaryDimEnc.ENCODING_NAME.equals(encoding))
{
+            assertEquals(null, encoding);
+        } else if (encoding.startsWith("dict")) {
+            assertTrue(encoding.startsWith("dict"));
+        } else {
+            assertEquals("dict", encoding);
+        }
+    }
+
+    @Test
+    public void testNonDictProcessLogic() throws Exception {
+        String encoding = "boolean";
+        if (StringUtils.isEmpty(encoding) || DictionaryDimEnc.ENCODING_NAME.equals(encoding))
{
+            assertEquals(null, encoding);
+        } else if (encoding.startsWith("dict")) {
+            assertTrue(encoding.startsWith("dict"));
+        } else {
+            assertEquals("boolean", encoding);
+        }
+    }
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message