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 2018/07/20 09:24:38 UTC
[kylin] branch 2.4.x updated: KYLIN-3255 cannot save cube and unit
test
This is an automated email from the ASF dual-hosted git repository.
shaofengshi pushed a commit to branch 2.4.x
in repository https://gitbox.apache.org/repos/asf/kylin.git
The following commit(s) were added to refs/heads/2.4.x by this push:
new bf58a5d KYLIN-3255 cannot save cube and unit test
bf58a5d is described below
commit bf58a5d34bb64c2954d0b112ec8e77d36d92b60a
Author: GinaZhai <na...@kyligence.io>
AuthorDate: Wed Jul 18 18:55:56 2018 +0800
KYLIN-3255 cannot save cube and unit test
KYLIN-3255 bug fix
KYLIN-3255 Unit Test
---
.../org/apache/kylin/cube/CubeDescManager.java | 12 ++--
.../org/apache/kylin/cube/CubeDescManagerTest.java | 78 ++++++++++++++++++++++
2 files changed, 83 insertions(+), 7 deletions(-)
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 db42263..4fb9522 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 @@ public class CubeDescManager {
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 0000000..01336bc
--- /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);
+ }
+ }
+}