You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ma...@apache.org on 2015/05/15 07:21:40 UTC
[11/52] [abbrv] incubator-kylin git commit: KYLIN-766 fix test case
after-effects of BigDecimalSerializer truncating
KYLIN-766 fix test case after-effects of BigDecimalSerializer truncating
Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/4b508345
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/4b508345
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/4b508345
Branch: refs/heads/0.8.0
Commit: 4b5083454e9475657fc2532a1261fa861ab653df
Parents: 4cf65f0
Author: honma <ho...@ebay.com>
Authored: Fri May 15 11:13:57 2015 +0800
Committer: honma <ho...@ebay.com>
Committed: Fri May 15 11:14:04 2015 +0800
----------------------------------------------------------------------
.../kylin/cube/kv/RowValueDecoderTest.java | 29 +++++++++++++++-----
.../metadata/measure/MeasureCodecTest.java | 20 +++++++-------
2 files changed, 32 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/4b508345/cube/src/test/java/org/apache/kylin/cube/kv/RowValueDecoderTest.java
----------------------------------------------------------------------
diff --git a/cube/src/test/java/org/apache/kylin/cube/kv/RowValueDecoderTest.java b/cube/src/test/java/org/apache/kylin/cube/kv/RowValueDecoderTest.java
index 3b1954b..369e6f6 100644
--- a/cube/src/test/java/org/apache/kylin/cube/kv/RowValueDecoderTest.java
+++ b/cube/src/test/java/org/apache/kylin/cube/kv/RowValueDecoderTest.java
@@ -18,12 +18,6 @@
package org.apache.kylin.cube.kv;
-import static org.junit.Assert.*;
-
-import java.math.BigDecimal;
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-
import org.apache.hadoop.io.LongWritable;
import org.apache.kylin.common.util.LocalFileMetadataTestCase;
import org.apache.kylin.cube.CubeManager;
@@ -37,6 +31,12 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import java.math.BigDecimal;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
+
/**
* @author George Song (ysong1)
*
@@ -80,7 +80,22 @@ public class RowValueDecoderTest extends LocalFileMetadataTestCase {
rowValueDecoder.decode(valueBytes);
Object[] measureValues = rowValueDecoder.getValues();
- assertEquals("[333.1234567, 333.1111111, 333.1999999, 2]", Arrays.toString(measureValues));
+ //BigDecimal.ROUND_HALF_EVEN in BigDecimalSerializer
+ assertEquals("[333.1235, 333.1111, 333.2000, 2]", Arrays.toString(measureValues));
}
+ @Test(expected = IllegalArgumentException.class)
+ public void testError() throws Exception {
+ CubeDesc cubeDesc = CubeManager.getInstance(getTestConfig()).getCube("test_kylin_cube_with_slr_ready").getDescriptor();
+ HBaseColumnDesc hbaseCol = cubeDesc.getHBaseMapping().getColumnFamily()[0].getColumns()[0];
+
+ MeasureCodec codec = new MeasureCodec(hbaseCol.getMeasures());
+ BigDecimal sum = new BigDecimal("11111111111111111111333.1234567");
+ BigDecimal min = new BigDecimal("333.1111111");
+ BigDecimal max = new BigDecimal("333.1999999");
+ LongWritable count = new LongWritable(2);
+ ByteBuffer buf = ByteBuffer.allocate(RowConstants.ROWVALUE_BUFFER_SIZE);
+ codec.encode(new Object[] { sum, min, max, count }, buf);
+
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/4b508345/cube/src/test/java/org/apache/kylin/metadata/measure/MeasureCodecTest.java
----------------------------------------------------------------------
diff --git a/cube/src/test/java/org/apache/kylin/metadata/measure/MeasureCodecTest.java b/cube/src/test/java/org/apache/kylin/metadata/measure/MeasureCodecTest.java
index ddb624e..7243289 100644
--- a/cube/src/test/java/org/apache/kylin/metadata/measure/MeasureCodecTest.java
+++ b/cube/src/test/java/org/apache/kylin/metadata/measure/MeasureCodecTest.java
@@ -18,20 +18,19 @@
package org.apache.kylin.metadata.measure;
-import static org.junit.Assert.*;
-
-import java.math.BigDecimal;
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-
import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.LongWritable;
-import org.junit.Test;
-
import org.apache.kylin.common.hll.HyperLogLogPlusCounter;
import org.apache.kylin.cube.kv.RowConstants;
-import org.apache.kylin.metadata.model.MeasureDesc;
import org.apache.kylin.metadata.model.FunctionDesc;
+import org.apache.kylin.metadata.model.MeasureDesc;
+import org.junit.Test;
+
+import java.math.BigDecimal;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+
+import static org.junit.Assert.assertTrue;
/**
* @author yangli9
@@ -46,7 +45,7 @@ public class MeasureCodecTest {
DoubleWritable d = new DoubleWritable(1.0);
LongWritable l = new LongWritable(2);
- BigDecimal b = new BigDecimal("333.1234567");
+ BigDecimal b = new BigDecimal("333.1234");
HyperLogLogPlusCounter hllc = new HyperLogLogPlusCounter(16);
hllc.add("1234567");
hllc.add("abcdefg");
@@ -62,6 +61,7 @@ public class MeasureCodecTest {
System.out.println("size: " + buf.limit());
Object copy[] = new Object[values.length];
+
codec.decode(buf, copy);
assertTrue(Arrays.equals(values, copy));