You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ja...@apache.org on 2017/07/12 15:05:16 UTC
[40/50] [abbrv] carbondata git commit: [CARBONDATA-1267] Add
short_int case branch in DeltaIntegalCodec
[CARBONDATA-1267] Add short_int case branch in DeltaIntegalCodec
This closes #1139
Project: http://git-wip-us.apache.org/repos/asf/carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/carbondata/commit/c6bc1f07
Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/c6bc1f07
Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/c6bc1f07
Branch: refs/heads/datamap
Commit: c6bc1f07180c4740ba9b3e518ead34daa093be1c
Parents: 0558c28
Author: xuchuanyin <xu...@hust.edu.cn>
Authored: Wed Jul 5 21:00:45 2017 +0800
Committer: jackylk <ja...@huawei.com>
Committed: Mon Jul 10 21:19:45 2017 +0800
----------------------------------------------------------------------
.../page/encoding/DeltaIntegerCodec.java | 12 +++++++
.../test/resources/short_int_as_target_type.csv | 3 ++
.../aggquery/IntegerDataTypeTestCase.scala | 33 +++++++++++++++++++-
3 files changed, 47 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/carbondata/blob/c6bc1f07/core/src/main/java/org/apache/carbondata/core/datastore/page/encoding/DeltaIntegerCodec.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/datastore/page/encoding/DeltaIntegerCodec.java b/core/src/main/java/org/apache/carbondata/core/datastore/page/encoding/DeltaIntegerCodec.java
index b77f7a2..6cf59a6 100644
--- a/core/src/main/java/org/apache/carbondata/core/datastore/page/encoding/DeltaIntegerCodec.java
+++ b/core/src/main/java/org/apache/carbondata/core/datastore/page/encoding/DeltaIntegerCodec.java
@@ -120,6 +120,9 @@ public class DeltaIntegerCodec extends AdaptiveCompressionCodec {
case SHORT:
encodedPage.putShort(rowId, (short)(max - value));
break;
+ case SHORT_INT:
+ encodedPage.putShortInt(rowId, (int)(max - value));
+ break;
case INT:
encodedPage.putInt(rowId, (int)(max - value));
break;
@@ -137,6 +140,9 @@ public class DeltaIntegerCodec extends AdaptiveCompressionCodec {
case SHORT:
encodedPage.putShort(rowId, (short)(max - value));
break;
+ case SHORT_INT:
+ encodedPage.putShortInt(rowId, (int)(max - value));
+ break;
case INT:
encodedPage.putInt(rowId, (int)(max - value));
break;
@@ -157,6 +163,9 @@ public class DeltaIntegerCodec extends AdaptiveCompressionCodec {
case SHORT:
encodedPage.putShort(rowId, (short)(max - value));
break;
+ case SHORT_INT:
+ encodedPage.putShortInt(rowId, (int)(max - value));
+ break;
case INT:
encodedPage.putInt(rowId, (int)(max - value));
break;
@@ -177,6 +186,9 @@ public class DeltaIntegerCodec extends AdaptiveCompressionCodec {
case SHORT:
encodedPage.putShort(rowId, (short)(max - value));
break;
+ case SHORT_INT:
+ encodedPage.putShortInt(rowId, (int)(max - value));
+ break;
case INT:
encodedPage.putInt(rowId, (int)(max - value));
break;
http://git-wip-us.apache.org/repos/asf/carbondata/blob/c6bc1f07/integration/spark-common-test/src/test/resources/short_int_as_target_type.csv
----------------------------------------------------------------------
diff --git a/integration/spark-common-test/src/test/resources/short_int_as_target_type.csv b/integration/spark-common-test/src/test/resources/short_int_as_target_type.csv
new file mode 100644
index 0000000..964517e
--- /dev/null
+++ b/integration/spark-common-test/src/test/resources/short_int_as_target_type.csv
@@ -0,0 +1,3 @@
+begin_time,name
+1497376581,name1
+1497423838,name2
http://git-wip-us.apache.org/repos/asf/carbondata/blob/c6bc1f07/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/aggquery/IntegerDataTypeTestCase.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/aggquery/IntegerDataTypeTestCase.scala b/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/aggquery/IntegerDataTypeTestCase.scala
index 8e19684..f918301 100644
--- a/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/aggquery/IntegerDataTypeTestCase.scala
+++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/aggquery/IntegerDataTypeTestCase.scala
@@ -112,6 +112,37 @@ class IntegerDataTypeTestCase extends QueryTest with BeforeAndAfterAll {
""".stripMargin)
}
+ test("short int as target type in deltaIntegerCodec") {
+ sql(
+ """
+ | DROP TABLE IF EXISTS short_int_target_table
+ """.stripMargin)
+
+ //begin_time column will be encoded by deltaIntegerCodec
+ sql(
+ """
+ | CREATE TABLE short_int_target_table
+ | (begin_time bigint, name string)
+ | STORED BY 'org.apache.carbondata.format'
+ """.stripMargin)
+
+ sql(
+ s"""
+ | LOAD DATA LOCAL INPATH '$resourcesPath/short_int_as_target_type.csv'
+ | INTO TABLE short_int_target_table
+ """.stripMargin)
+
+ checkAnswer(
+ sql("select begin_time from short_int_target_table"),
+ Seq(Row(1497376581), Row(1497423838))
+ )
+
+ sql(
+ """
+ | DROP TABLE short_int_target_table
+ """.stripMargin)
+ }
+
override def afterAll {
sql("drop table if exists integertypetableAgg")
CarbonProperties.getInstance().addProperty(
@@ -119,4 +150,4 @@ class IntegerDataTypeTestCase extends QueryTest with BeforeAndAfterAll {
CarbonCommonConstants.ENABLE_UNSAFE_COLUMN_PAGE_LOADING_DEFAULT
)
}
-}
\ No newline at end of file
+}