You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2021/11/18 07:47:51 UTC
[iotdb] 03/04: add some tests
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch ty_new_vector
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit e6297eb4528f757207949d4af90da68c867724ba
Author: JackieTien97 <Ja...@foxmail.com>
AuthorDate: Thu Nov 18 12:06:54 2021 +0800
add some tests
---
.../db/integration/aligned/AlignedWriter.java | 155 +++++++++++++++++++++
.../aligned/IoTDBRawQueryWithoutValueFilterIT.java | 121 ++++++++++++++++
2 files changed, 276 insertions(+)
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/aligned/AlignedWriter.java b/server/src/test/java/org/apache/iotdb/db/integration/aligned/AlignedWriter.java
new file mode 100644
index 0000000..dd7244c
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/integration/aligned/AlignedWriter.java
@@ -0,0 +1,155 @@
+/*
+ * 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.iotdb.db.integration.aligned;
+
+import org.apache.iotdb.db.utils.EnvironmentUtils;
+import org.apache.iotdb.jdbc.Config;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+
+public class AlignedWriter {
+
+ private static final String[] sqls =
+ new String[] {
+ "SET STORAGE GROUP TO root.sg1",
+ "create aligned timeseries root.sg1.d1(s1 FLOAT encoding=RLE, s2 INT32 encoding=Grollia compression=SNAPPY, s3 INT64, s4 BOOLEAN, s5 TEXT) compression=SNAPPY",
+ "create timeseries root.sg1.d2.s1 WITH DATATYPE=FLOAT, encoding=RLE",
+ "create timeseries root.sg1.d2.s2 WITH DATATYPE=INT32, encoding=Grollia",
+ "create timeseries root.sg1.d2.s3 WITH DATATYPE=INT64",
+ "create timeseries root.sg1.d2.s4 WITH DATATYPE=BOOLEAN",
+ "create timeseries root.sg1.d2.s5 WITH DATATYPE=TEXT",
+ "insert into root.sg1.d1(time, s1, s2, s3, s4, s5) aligned values(1, 1.0, 1, 1, TRUE, 'aligned_test1')",
+ "insert into root.sg1.d1(time, s1, s2, s3, s5) aligned values(2, 2.0, 2, 2, 'aligned_test2')",
+ "insert into root.sg1.d1(time, s1, s3, s4, s5) aligned values(3, 3.0, 3, FALSE, 'aligned_test3')",
+ "insert into root.sg1.d1(time, s1, s2, s4, s5) aligned values(4, 4.0, 4, TRUE, 'aligned_test4')",
+ "insert into root.sg1.d1(time, s1, s2, s4, s5) aligned values(5, 5.0, 5, TRUE, 'aligned_test5')",
+ "insert into root.sg1.d1(time, s1, s2, s3, s4) aligned values(6, 6.0, 6, 6, TRUE)",
+ "insert into root.sg1.d1(time, s1, s2, s3, s4, s5) aligned values(7, 7.0, 7, 7, FALSE, 'aligned_test7')",
+ "insert into root.sg1.d1(time, s1, s2, s3, s5) aligned values(8, 8.0, 8, 8, 'aligned_test8')",
+ "insert into root.sg1.d1(time, s1, s2, s3, s4, s5) aligned values(9, 9.0, 9, 9, FALSE, 'aligned_test9')",
+ "insert into root.sg1.d1(time, s2, s3, s4, s5) aligned values(10, 10, 10, TRUE, 'aligned_test10')",
+ "insert into root.sg1.d2(time, s1, s2, s3, s4, s5) values(1, 1.0, 1, 1, TRUE, 'non_aligned_test1')",
+ "insert into root.sg1.d2(time, s1, s2, s3, s5) values(2, 2.0, 2, 2, 'non_aligned_test2')",
+ "insert into root.sg1.d2(time, s1, s3, s4, s5) values(3, 3.0, 3, FALSE, 'non_aligned_test3')",
+ "insert into root.sg1.d2(time, s1, s2, s4, s5) values(4, 4.0, 4, TRUE, 'non_aligned_test4')",
+ "insert into root.sg1.d2(time, s1, s2, s4, s5) values(5, 5.0, 5, TRUE, 'non_aligned_test5')",
+ "insert into root.sg1.d2(time, s1, s2, s3, s4) values(6, 6.0, 6, 6, TRUE)",
+ "insert into root.sg1.d2(time, s1, s2, s3, s4, s5) values(7, 7.0, 7, 7, FALSE, 'non_aligned_test7')",
+ "insert into root.sg1.d2(time, s1, s2, s3, s5) values(8, 8.0, 8, 8, 'non_aligned_test8')",
+ "insert into root.sg1.d2(time, s1, s2, s3, s4, s5) values(9, 9.0, 9, 9, FALSE, 'non_aligned_test9')",
+ "insert into root.sg1.d2(time, s2, s3, s4, s5) values(10, 10, 10, TRUE, 'non_aligned_test10')",
+ "flush",
+ "insert into root.sg1.d1(time, s1, s2, s3) aligned values(11, 11.0, 11, 11)",
+ "insert into root.sg1.d1(time, s1, s2, s3) aligned values(12, 12.0, 12, 12)",
+ "insert into root.sg1.d1(time, s1, s2, s3) aligned values(13, 13.0, 13, 13)",
+ "insert into root.sg1.d1(time, s1, s2, s3) aligned values(14, 14.0, 14, 14)",
+ "insert into root.sg1.d1(time, s1, s2, s3) aligned values(15, 15.0, 15, 15)",
+ "insert into root.sg1.d1(time, s1, s2, s3) aligned values(16, 16.0, 16, 16)",
+ "insert into root.sg1.d1(time, s1, s2, s3) aligned values(17, 17.0, 17, 17)",
+ "insert into root.sg1.d1(time, s1, s2, s3) aligned values(18, 18.0, 18, 18)",
+ "insert into root.sg1.d1(time, s1, s2, s3) aligned values(19, 19.0, 19, 19)",
+ "insert into root.sg1.d1(time, s1, s2, s3) aligned values(20, 20.0, 20, 20)",
+ "insert into root.sg1.d2(time, s1, s2, s3) values(11, 11.0, 11, 11)",
+ "insert into root.sg1.d2(time, s1, s2, s3) values(12, 12.0, 12, 12)",
+ "insert into root.sg1.d2(time, s1, s2, s3) values(13, 13.0, 13, 13)",
+ "insert into root.sg1.d2(time, s1, s2, s3) values(14, 14.0, 14, 14)",
+ "insert into root.sg1.d2(time, s1, s2, s3) values(15, 15.0, 15, 15)",
+ "insert into root.sg1.d2(time, s1, s2, s3) values(16, 16.0, 16, 16)",
+ "insert into root.sg1.d2(time, s1, s2, s3) values(17, 17.0, 17, 17)",
+ "insert into root.sg1.d2(time, s1, s2, s3) values(18, 18.0, 18, 18)",
+ "insert into root.sg1.d2(time, s1, s2, s3) values(19, 19.0, 19, 19)",
+ "insert into root.sg1.d2(time, s1, s2, s3) values(20, 20.0, 20, 20)",
+ "flush",
+ "insert into root.sg1.d1(time, s3, s4) aligned values(21, 21, TRUE)",
+ "insert into root.sg1.d1(time, s3, s4) aligned values(22, 22, TRUE)",
+ "insert into root.sg1.d1(time, s3, s4) aligned values(23, 23, TRUE)",
+ "insert into root.sg1.d1(time, s3, s4) aligned values(24, 24, TRUE)",
+ "insert into root.sg1.d1(time, s3, s4) aligned values(25, 25, TRUE)",
+ "insert into root.sg1.d1(time, s3, s4) aligned values(26, 26, FALSE)",
+ "insert into root.sg1.d1(time, s3, s4) aligned values(27, 27, FALSE)",
+ "insert into root.sg1.d1(time, s3, s4) aligned values(28, 28, FALSE)",
+ "insert into root.sg1.d1(time, s3, s4) aligned values(29, 29, FALSE)",
+ "insert into root.sg1.d1(time, s3, s4) aligned values(30, 30, FALSE)",
+ "insert into root.sg1.d2(time, s3, s4) values(21, 21, TRUE)",
+ "insert into root.sg1.d2(time, s3, s4) values(22, 21, TRUE)",
+ "insert into root.sg1.d2(time, s3, s4) values(23, 23, TRUE)",
+ "insert into root.sg1.d2(time, s3, s4) values(24, 24, TRUE)",
+ "insert into root.sg1.d2(time, s3, s4) values(25, 25, TRUE)",
+ "insert into root.sg1.d2(time, s3, s4) values(26, 26, FALSE)",
+ "insert into root.sg1.d2(time, s3, s4) values(27, 27, FALSE)",
+ "insert into root.sg1.d2(time, s3, s4) values(28, 28, FALSE)",
+ "insert into root.sg1.d2(time, s3, s4) values(29, 29, FALSE)",
+ "insert into root.sg1.d2(time, s3, s4) values(30, 30, FALSE)",
+ "flush",
+ "insert into root.sg1.d1(time, s2, s5) aligned values(31, 31, 'aligned_test31')",
+ "insert into root.sg1.d1(time, s2, s5) aligned values(32, 32, 'aligned_test32')",
+ "insert into root.sg1.d1(time, s2, s5) aligned values(33, 33, 'aligned_test33')",
+ "insert into root.sg1.d1(time, s2, s5) aligned values(34, 34, 'aligned_test34')",
+ "insert into root.sg1.d1(time, s2, s5) aligned values(35, 35, 'aligned_test35')",
+ "insert into root.sg1.d1(time, s2, s5) aligned values(36, 36, 'aligned_test36')",
+ "insert into root.sg1.d1(time, s2, s5) aligned values(37, 37, 'aligned_test37')",
+ "insert into root.sg1.d1(time, s2, s5) aligned values(38, 38, 'aligned_test38')",
+ "insert into root.sg1.d1(time, s2, s5) aligned values(39, 39, 'aligned_test39')",
+ "insert into root.sg1.d1(time, s2, s5) aligned values(40, 40, 'aligned_test40')",
+ "insert into root.sg1.d2(time, s2, s5) values(31, 31, 'non_aligned_test31')",
+ "insert into root.sg1.d2(time, s2, s5) values(32, 32, 'non_aligned_test32')",
+ "insert into root.sg1.d2(time, s2, s5) values(33, 33, 'non_aligned_test33')",
+ "insert into root.sg1.d2(time, s2, s5) values(34, 34, 'non_aligned_test34')",
+ "insert into root.sg1.d2(time, s2, s5) values(35, 35, 'non_aligned_test35')",
+ "insert into root.sg1.d2(time, s2, s5) values(36, 36, 'non_aligned_test36')",
+ "insert into root.sg1.d2(time, s2, s5) values(37, 37, 'non_aligned_test37')",
+ "insert into root.sg1.d2(time, s2, s5) values(38, 38, 'non_aligned_test38')",
+ "insert into root.sg1.d2(time, s2, s5) values(39, 39, 'non_aligned_test39')",
+ "insert into root.sg1.d2(time, s2, s5) values(40, 40, 'non_aligned_test40')",
+ "flush",
+ };
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ EnvironmentUtils.closeStatMonitor();
+ EnvironmentUtils.envSetUp();
+ insertData();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ EnvironmentUtils.cleanEnv();
+ }
+
+ private static void insertData() throws ClassNotFoundException {
+ Class.forName(Config.JDBC_DRIVER_NAME);
+ try (Connection connection =
+ DriverManager.getConnection(
+ Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement()) {
+
+ // create aligned and non-aligned time series
+ for (String sql : sqls) {
+ statement.execute(sql);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBRawQueryWithoutValueFilterIT.java b/server/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBRawQueryWithoutValueFilterIT.java
new file mode 100644
index 0000000..0b61709
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBRawQueryWithoutValueFilterIT.java
@@ -0,0 +1,121 @@
+/*
+ * 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.iotdb.db.integration.aligned;
+
+import org.apache.iotdb.jdbc.Config;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+public class IoTDBRawQueryWithoutValueFilterIT extends AlignedWriter {
+
+ @Test
+ public void selectAllAlignedWithoutValueFilterTest() throws ClassNotFoundException {
+
+ String[] retArray =
+ new String[] {
+ "1,1.0,1,1,true,aligned_test1",
+ "2,2.0,2,2,null,aligned_test2",
+ "3,3.0,null,3,false,aligned_test3",
+ "4,4.0,4,null,true,aligned_test4",
+ "5,5.0,5,null,true,aligned_test5",
+ "6,6.0,6,6,true,null",
+ "7,7.0,7,7,false,aligned_test7",
+ "8,8.0,8,8,null,aligned_test8",
+ "9,9.0,9,9,false,aligned_test9",
+ "10,null,10,10,true,aligned_test10",
+ "11,11.0,11,11,null,null",
+ "12,12.0,12,12,null,null",
+ "13,13.0,13,13,null,null",
+ "14,14.0,14,14,null,null",
+ "15,15.0,15,15,null,null",
+ "16,16.0,16,16,null,null",
+ "17,17.0,17,17,null,null",
+ "18,18.0,18,18,null,null",
+ "19,19.0,19,19,null,null",
+ "20,20.0,20,20,null,null",
+ "21,null,null,21,21,true,null",
+ "22,null,null,22,22,true,null",
+ "23,null,null,23,23,true,null",
+ "24,null,null,24,24,true,null",
+ "25,null,null,25,25,true,null",
+ "26,null,null,26,26,false,null",
+ "27,null,null,27,27,false,null",
+ "28,null,null,28,28,false,null",
+ "29,null,null,29,29,false,null",
+ "30,null,null,30,30,false,null",
+ "31,null,31,null,null,aligned_test31",
+ "32,null,32,null,null,aligned_test32",
+ "33,null,33,null,null,aligned_test33",
+ "34,null,34,null,null,aligned_test34",
+ "35,null,35,null,null,aligned_test35",
+ "36,null,36,null,null,aligned_test36",
+ "37,null,37,null,null,aligned_test37",
+ "38,null,38,null,null,aligned_test38",
+ "39,null,39,null,null,aligned_test39",
+ "40,null,40,null,null,aligned_test40",
+ };
+
+ Class.forName(Config.JDBC_DRIVER_NAME);
+ try (Connection connection =
+ DriverManager.getConnection(
+ Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement()) {
+
+ boolean hasResultSet = statement.execute("select * from root.sg1.d1");
+ Assert.assertTrue(hasResultSet);
+
+ try (ResultSet resultSet = statement.getResultSet()) {
+ ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
+ Map<String, Integer> map = new HashMap<>();
+ for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
+ map.put(resultSetMetaData.getColumnName(i), i);
+ }
+ int cnt = 0;
+ while (resultSet.next()) {
+ StringBuilder builder = new StringBuilder();
+ builder.append(resultSet.getString(1)).append(",");
+ for (int i = 1; i <= 5; i++) {
+ int index = map.get("root.sg1.d1.s" + i);
+ builder.append(resultSet.getString(index)).append(",");
+ }
+ assertEquals(retArray[cnt], builder.toString());
+ cnt++;
+ }
+ assertEquals(retArray.length, cnt);
+ }
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+}