You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2022/03/12 13:00:34 UTC
[iotdb] 01/01: [IOTDB-2461] Add cpp and sql support for ZIPZAP encoding
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch iotdb_2461
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 35ab5d1fcb28ed6ac6f00e09d50dcc8e2604e877
Author: HTHou <hh...@outlook.com>
AuthorDate: Sat Mar 12 20:59:47 2022 +0800
[IOTDB-2461] Add cpp and sql support for ZIPZAP encoding
---
.../antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 | 5 +-
client-cpp/src/main/Session.h | 3 +-
.../iotdb/db/integration/IoTDBEncodingIT.java | 56 ++++++++++++++++++++++
3 files changed, 62 insertions(+), 2 deletions(-)
diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
index 89a4603..c08d2c9 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
@@ -633,7 +633,7 @@ TEXT
// Encoding Type Keywords
ENCODING_VALUE
- : DICTIONARY | DIFF | GORILLA | PLAIN | REGULAR | RLE | TS_2DIFF
+ : DICTIONARY | DIFF | GORILLA | PLAIN | REGULAR | RLE | TS_2DIFF | ZIGZAG
;
DICTIONARY
@@ -664,6 +664,9 @@ TS_2DIFF
: T S '_' '2' D I F F
;
+ZIGZAG
+ : Z I G Z A G
+ ;
// Compressor Type Keywords
diff --git a/client-cpp/src/main/Session.h b/client-cpp/src/main/Session.h
index 3a93a8e..c8b8326 100644
--- a/client-cpp/src/main/Session.h
+++ b/client-cpp/src/main/Session.h
@@ -143,7 +143,8 @@ namespace TSEncoding {
BITMAP = (char) 5,
GORILLA_V1 = (char) 6,
REGULAR = (char) 7,
- GORILLA = (char) 8
+ GORILLA = (char) 8,
+ ZIGZAG = (char) 9
};
}
diff --git a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBEncodingIT.java b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBEncodingIT.java
index 65d30b1..3d54ed6 100644
--- a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBEncodingIT.java
+++ b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBEncodingIT.java
@@ -244,6 +244,62 @@ public class IoTDBEncodingIT {
}
@Test
+ public void testSetTimeEncoderRegularAndValueEncoderZIGZAG() {
+ try (Connection connection =
+ DriverManager.getConnection(
+ Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement()) {
+ statement.execute(
+ "CREATE TIMESERIES root.db_0.tab0.salary WITH DATATYPE=INT64,ENCODING=ZIGZAG");
+ statement.execute("insert into root.db_0.tab0(time,salary) values(1,1100)");
+ statement.execute("insert into root.db_0.tab0(time,salary) values(2,1200)");
+ statement.execute("insert into root.db_0.tab0(time,salary) values(3,1300)");
+ statement.execute("insert into root.db_0.tab0(time,salary) values(4,1400)");
+ statement.execute("flush");
+
+ int[] result = new int[] {1100, 1200, 1300, 1400};
+ try (ResultSet resultSet = statement.executeQuery("select * from root.db_0.tab0")) {
+ int index = 0;
+ while (resultSet.next()) {
+ int salary = resultSet.getInt("root.db_0.tab0.salary");
+ assertEquals(result[index], salary);
+ index++;
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testSetTimeEncoderRegularAndValueEncoderZIGZAGOutofOrder() {
+ try (Connection connection =
+ DriverManager.getConnection(
+ Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement()) {
+ statement.execute(
+ "CREATE TIMESERIES root.db_0.tab0.salary WITH DATATYPE=INT64,ENCODING=ZIGZAG");
+ statement.execute("insert into root.db_0.tab0(time,salary) values(1,1200)");
+ statement.execute("insert into root.db_0.tab0(time,salary) values(2,1100)");
+ statement.execute("insert into root.db_0.tab0(time,salary) values(7,1000)");
+ statement.execute("insert into root.db_0.tab0(time,salary) values(4,2200)");
+ statement.execute("flush");
+
+ int[] result = new int[] {1200, 1100, 2200, 1000};
+ try (ResultSet resultSet = statement.executeQuery("select * from root.db_0.tab0")) {
+ int index = 0;
+ while (resultSet.next()) {
+ int salary = resultSet.getInt("root.db_0.tab0.salary");
+ assertEquals(result[index], salary);
+ index++;
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
public void testSetTimeEncoderRegularAndValueEncoderDictionary() {
try (Connection connection =
DriverManager.getConnection(