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/01/22 04:13:10 UTC

kylin git commit: KYLIN-1334 allow truncating string for fixed length dimensions

Repository: kylin
Updated Branches:
  refs/heads/2.0-rc 30f1cfffa -> a118a27c6


KYLIN-1334 allow truncating string for fixed length dimensions

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

Branch: refs/heads/2.0-rc
Commit: a118a27c6c7aa5a8dd1803b817eaa205b7953373
Parents: 30f1cff
Author: shaofengshi <sh...@apache.org>
Authored: Fri Jan 22 11:13:02 2016 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Fri Jan 22 11:13:02 2016 +0800

----------------------------------------------------------------------
 .../org/apache/kylin/cube/gridtable/FixLenSerializer.java    | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/a118a27c/core-cube/src/main/java/org/apache/kylin/cube/gridtable/FixLenSerializer.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/gridtable/FixLenSerializer.java b/core-cube/src/main/java/org/apache/kylin/cube/gridtable/FixLenSerializer.java
index 085eb55..f0522fa 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/gridtable/FixLenSerializer.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/gridtable/FixLenSerializer.java
@@ -26,9 +26,13 @@ import org.apache.kylin.common.util.Bytes;
 import org.apache.kylin.cube.kv.RowConstants;
 import org.apache.kylin.dict.Dictionary;
 import org.apache.kylin.metadata.measure.serializer.DataTypeSerializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class FixLenSerializer extends DataTypeSerializer {
 
+    private static Logger logger = LoggerFactory.getLogger(FixLenSerializer.class);
+
     // be thread-safe and avoid repeated obj creation
     private ThreadLocal<byte[]> current = new ThreadLocal<byte[]>();
 
@@ -56,9 +60,9 @@ public class FixLenSerializer extends DataTypeSerializer {
         } else {
             byte[] bytes = Bytes.toBytes(value.toString());
             if (bytes.length > fixLen) {
-                throw new IllegalStateException("Expect at most " + fixLen + " bytes, but got " + bytes.length + ", value string: " + value.toString());
+                logger.warn("Expect at most " + fixLen + " bytes, but got " + bytes.length + ", will truncate, value string: " + value.toString());
             }
-            out.put(bytes);
+            out.put(bytes, 0, Math.min(bytes.length, fixLen));
             for (int i = bytes.length; i < fixLen; i++) {
                 out.put(RowConstants.ROWKEY_PLACE_HOLDER_BYTE);
             }