This is an automated email from the ASF dual-hosted git repository.
xiangweiwei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new f6068ab1a3 [IOTDB-3436] add aggregation with value filter IT (#6389)
f6068ab1a3 is described below
commit f6068ab1a33588bb8643fb97a5fa7ce56f707750
Author: Xiangwei Wei <[email protected]>
AuthorDate: Thu Jun 23 22:14:34 2022 +0800
[IOTDB-3436] add aggregation with value filter IT (#6389)
---
...T.java => IoTDBAggregationWithDeletion2IT.java} | 3 +-
...IT.java => IoTDBAggregationWithDeletionIT.java} | 117 ++++++++-
.../db/it/aligned/IoTDBAlignedSeriesQueryIT.java | 167 +++++++++++++
.../IoTDBAggregationWithValueFilter2IT.java | 65 -----
.../aligned/IoTDBAggregationWithValueFilterIT.java | 264 ---------------------
...BAggregationWithValueFilterWithDeletion2IT.java | 85 -------
...DBAggregationWithValueFilterWithDeletionIT.java | 221 -----------------
7 files changed, 284 insertions(+), 638 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBAggregationWithoutValueFilterWithDeletion2IT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBAggregationWithDeletion2IT.java
similarity index 96%
rename from
integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBAggregationWithoutValueFilterWithDeletion2IT.java
rename to
integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBAggregationWithDeletion2IT.java
index f7c1f24bc0..5a7b861fcf 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBAggregationWithoutValueFilterWithDeletion2IT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBAggregationWithDeletion2IT.java
@@ -37,8 +37,7 @@ import static org.junit.Assert.fail;
/** Let One chunk has more than one page. */
@RunWith(IoTDBTestRunner.class)
@Category({LocalStandaloneIT.class, ClusterIT.class})
-public class IoTDBAggregationWithoutValueFilterWithDeletion2IT
- extends IoTDBAggregationWithoutValueFilterWithDeletionIT {
+public class IoTDBAggregationWithDeletion2IT extends
IoTDBAggregationWithDeletionIT {
private static int numOfPointsPerPage;
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBAggregationWithoutValueFilterWithDeletionIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBAggregationWithDeletionIT.java
similarity index 76%
rename from
integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBAggregationWithoutValueFilterWithDeletionIT.java
rename to
integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBAggregationWithDeletionIT.java
index 2f3a09994d..9c201c2a49 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBAggregationWithoutValueFilterWithDeletionIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBAggregationWithDeletionIT.java
@@ -44,7 +44,7 @@ import static org.junit.Assert.fail;
@RunWith(IoTDBTestRunner.class)
@Category({LocalStandaloneIT.class, ClusterIT.class})
-public class IoTDBAggregationWithoutValueFilterWithDeletionIT {
+public class IoTDBAggregationWithDeletionIT {
private static final double DELTA = 1e-6;
protected static boolean enableSeqSpaceCompaction;
@@ -404,4 +404,119 @@ public class
IoTDBAggregationWithoutValueFilterWithDeletionIT {
fail(e.getMessage());
}
}
+
+ // ----------------------- Aggregation with value filter
-----------------------------
+ @Test
+ public void countAlignedWithValueFilterTest() throws ClassNotFoundException {
+ String[] retArray = new String[] {"11"};
+ String[] columnNames = {"count(root.sg1.d1.s4)"};
+ try (Connection connection = EnvFactory.getEnv().getConnection();
+ Statement statement = connection.createStatement()) {
+
+ try (ResultSet resultSet =
+ statement.executeQuery("select count(s4) from root.sg1.d1 where s4 =
true")) {
+ ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
+ Map<String, Integer> map = new HashMap<>(); // used to adjust result
sequence
+ for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
+ map.put(resultSetMetaData.getColumnName(i), i);
+ }
+ assertEquals(columnNames.length, resultSetMetaData.getColumnCount());
+ int cnt = 0;
+ while (resultSet.next()) {
+ String[] ans = new String[columnNames.length];
+ // No need to add time column for aggregation query
+ for (int i = 0; i < columnNames.length; i++) {
+ String columnName = columnNames[i];
+ int index = map.get(columnName);
+ ans[i] = resultSet.getString(index);
+ }
+ assertArrayEquals(retArray, ans);
+ cnt++;
+ }
+ assertEquals(1, cnt);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void countAllAlignedWithValueFilterTest() throws
ClassNotFoundException {
+ String[] retArray = new String[] {"0", "0", "9", "11", "6"};
+ String[] columnNames = {
+ "count(root.sg1.d1.s1)",
+ "count(root.sg1.d1.s2)",
+ "count(root.sg1.d1.s3)",
+ "count(root.sg1.d1.s4)",
+ "count(root.sg1.d1.s5)"
+ };
+ try (Connection connection = EnvFactory.getEnv().getConnection();
+ Statement statement = connection.createStatement()) {
+
+ try (ResultSet resultSet =
+ statement.executeQuery("select count(*) from root.sg1.d1 where s4 =
true")) {
+ ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
+ Map<String, Integer> map = new HashMap<>(); // used to adjust result
sequence
+ for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
+ map.put(resultSetMetaData.getColumnName(i), i);
+ }
+ assertEquals(columnNames.length, resultSetMetaData.getColumnCount());
+ int cnt = 0;
+ while (resultSet.next()) {
+ String[] ans = new String[columnNames.length];
+ // No need to add time column for aggregation query
+ for (int i = 0; i < columnNames.length; i++) {
+ String columnName = columnNames[i];
+ int index = map.get(columnName);
+ ans[i] = resultSet.getString(index);
+ }
+ assertArrayEquals(retArray, ans);
+ cnt++;
+ }
+ assertEquals(1, cnt);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void aggregationAllAlignedWithValueFilterTest() throws
ClassNotFoundException {
+ String[] retArray = new String[] {"0", "25", "1"};
+ String[] columnNames = {
+ "count(root.sg1.d1.s1)", "max_time(root.sg1.d1.s4)",
"min_value(root.sg1.d1.s3)",
+ };
+ try (Connection connection = EnvFactory.getEnv().getConnection();
+ Statement statement = connection.createStatement()) {
+
+ try (ResultSet resultSet =
+ statement.executeQuery(
+ "select count(s1), max_time(s4), min_value(s3) from root.sg1.d1
where s4 = true")) {
+ ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
+ Map<String, Integer> map = new HashMap<>(); // used to adjust result
sequence
+ for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
+ map.put(resultSetMetaData.getColumnName(i), i);
+ }
+ assertEquals(columnNames.length, resultSetMetaData.getColumnCount());
+ int cnt = 0;
+ while (resultSet.next()) {
+ String[] ans = new String[columnNames.length];
+ // No need to add time column for aggregation query
+ for (int i = 0; i < columnNames.length; i++) {
+ String columnName = columnNames[i];
+ int index = map.get(columnName);
+ ans[i] = resultSet.getString(index);
+ }
+ assertArrayEquals(retArray, ans);
+ cnt++;
+ }
+ assertEquals(1, cnt);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBAlignedSeriesQueryIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBAlignedSeriesQueryIT.java
index 37c7642d77..461d0caf05 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBAlignedSeriesQueryIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBAlignedSeriesQueryIT.java
@@ -1820,6 +1820,173 @@ public class IoTDBAlignedSeriesQueryIT {
}
}
+ // --------------------------------Aggregation with value
filter------------------------------
+ @Test
+ public void countAlignedWithValueFilterTest() {
+ String[] retArray = new String[] {"11"};
+ String[] columnNames = {"count(root.sg1.d1.s4)"};
+ try (Connection connection = EnvFactory.getEnv().getConnection();
+ Statement statement = connection.createStatement()) {
+
+ try (ResultSet resultSet =
+ statement.executeQuery("select count(s4) from root.sg1.d1 where s4 =
true")) {
+ ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
+ Map<String, Integer> map = new HashMap<>(); // used to adjust result
sequence
+ for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
+ map.put(resultSetMetaData.getColumnName(i), i);
+ }
+ assertEquals(columnNames.length, resultSetMetaData.getColumnCount());
+ int cnt = 0;
+ while (resultSet.next()) {
+ String[] ans = new String[columnNames.length];
+ // No need to add time column for aggregation query
+ for (int i = 0; i < columnNames.length; i++) {
+ String columnName = columnNames[i];
+ int index = map.get(columnName);
+ ans[i] = resultSet.getString(index);
+ }
+ assertArrayEquals(retArray, ans);
+ cnt++;
+ }
+ assertEquals(1, cnt);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void aggregationFuncAlignedWithValueFilterTest() throws
ClassNotFoundException {
+ String[] retArray = new String[] {"8", "42.0", "5.25", "1.0", "9.0", "1",
"9", "1.0", "9.0"};
+ String[] columnNames = {
+ "count(root.sg1.d1.s1)",
+ "sum(root.sg1.d1.s1)",
+ "avg(root.sg1.d1.s1)",
+ "first_value(root.sg1.d1.s1)",
+ "last_value(root.sg1.d1.s1)",
+ "min_time(root.sg1.d1.s1)",
+ "max_time(root.sg1.d1.s1)",
+ "min_value(root.sg1.d1.s1)",
+ "max_value(root.sg1.d1.s1)",
+ };
+ try (Connection connection = EnvFactory.getEnv().getConnection();
+ Statement statement = connection.createStatement()) {
+
+ try (ResultSet resultSet =
+ statement.executeQuery(
+ "select count(s1), sum(s1), avg(s1), "
+ + "first_value(s1), last_value(s1), "
+ + "min_time(s1), max_time(s1),"
+ + "max_value(s1), min_value(s1) from root.sg1.d1 where s1 <
10")) {
+ ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
+ Map<String, Integer> map = new HashMap<>(); // used to adjust result
sequence
+ for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
+ map.put(resultSetMetaData.getColumnName(i), i);
+ }
+ assertEquals(columnNames.length, resultSetMetaData.getColumnCount());
+ int cnt = 0;
+ while (resultSet.next()) {
+ String[] ans = new String[columnNames.length];
+ // No need to add time column for aggregation query
+ for (int i = 0; i < columnNames.length; i++) {
+ String columnName = columnNames[i];
+ int index = map.get(columnName);
+ ans[i] = resultSet.getString(index);
+ }
+ assertArrayEquals(retArray, ans);
+ cnt++;
+ }
+ assertEquals(1, cnt);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void countAllAlignedWithValueFilterTest() throws
ClassNotFoundException {
+ String[] retArray = new String[] {"6", "6", "9", "11", "6"};
+ String[] columnNames = {
+ "count(root.sg1.d1.s1)",
+ "count(root.sg1.d1.s2)",
+ "count(root.sg1.d1.s3)",
+ "count(root.sg1.d1.s4)",
+ "count(root.sg1.d1.s5)"
+ };
+ try (Connection connection = EnvFactory.getEnv().getConnection();
+ Statement statement = connection.createStatement()) {
+
+ try (ResultSet resultSet =
+ statement.executeQuery("select count(*) from root.sg1.d1 where s4 =
true")) {
+ ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
+ Map<String, Integer> map = new HashMap<>(); // used to adjust result
sequence
+ for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
+ map.put(resultSetMetaData.getColumnName(i), i);
+ }
+ assertEquals(columnNames.length, resultSetMetaData.getColumnCount());
+ int cnt = 0;
+ while (resultSet.next()) {
+ String[] ans = new String[columnNames.length];
+ // No need to add time column for aggregation query
+ for (int i = 0; i < columnNames.length; i++) {
+ String columnName = columnNames[i];
+ int index = map.get(columnName);
+ ans[i] = resultSet.getString(index);
+ }
+ assertArrayEquals(retArray, ans);
+ cnt++;
+ }
+ assertEquals(1, cnt);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void aggregationAllAlignedWithValueFilterTest() throws
ClassNotFoundException {
+ String[] retArray = new String[] {"160016.0", "11", "1", "13"};
+ String[] columnNames = {
+ "sum(root.sg1.d1.s1)",
+ "count(root.sg1.d1.s4)",
+ "min_value(root.sg1.d1.s3)",
+ "max_time(root.sg1.d1.s2)",
+ };
+ try (Connection connection = EnvFactory.getEnv().getConnection();
+ Statement statement = connection.createStatement()) {
+
+ try (ResultSet resultSet =
+ statement.executeQuery(
+ "select sum(s1), count(s4), min_value(s3), max_time(s2) from
root.sg1.d1 where s4 = true")) {
+ ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
+ Map<String, Integer> map = new HashMap<>(); // used to adjust result
sequence
+ for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
+ map.put(resultSetMetaData.getColumnName(i), i);
+ }
+ assertEquals(columnNames.length, resultSetMetaData.getColumnCount());
+ int cnt = 0;
+ while (resultSet.next()) {
+ String[] ans = new String[columnNames.length];
+ // No need to add time column for aggregation query
+ for (int i = 0; i < columnNames.length; i++) {
+ String columnName = columnNames[i];
+ int index = map.get(columnName);
+ ans[i] = resultSet.getString(index);
+ }
+ assertArrayEquals(retArray, ans);
+ cnt++;
+ }
+ assertEquals(1, cnt);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
// ---------------------------------Align by device query
------------------------------------
@Test
public void selectAllAlignedWithoutValueFilterAlignByDeviceTest() {
diff --git
a/integration/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBAggregationWithValueFilter2IT.java
b/integration/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBAggregationWithValueFilter2IT.java
deleted file mode 100644
index cdca91fc5b..0000000000
---
a/integration/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBAggregationWithValueFilter2IT.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.itbase.category.LocalStandaloneTest;
-import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.experimental.categories.Category;
-
-@Category({LocalStandaloneTest.class})
-/** Let One chunk has more than one page. */
-public class IoTDBAggregationWithValueFilter2IT extends
IoTDBAggregationWithValueFilterIT {
- private static int numOfPointsPerPage;
-
- @BeforeClass
- public static void setUp() throws Exception {
- EnvironmentUtils.envSetUp();
- // TODO When the aligned time series support compaction, we need to set
compaction to true
- enableSeqSpaceCompaction =
- IoTDBDescriptor.getInstance().getConfig().isEnableSeqSpaceCompaction();
- enableUnseqSpaceCompaction =
-
IoTDBDescriptor.getInstance().getConfig().isEnableUnseqSpaceCompaction();
- enableCrossSpaceCompaction =
-
IoTDBDescriptor.getInstance().getConfig().isEnableCrossSpaceCompaction();
- numOfPointsPerPage =
TSFileDescriptor.getInstance().getConfig().getMaxNumberOfPointsInPage();
-
IoTDBDescriptor.getInstance().getConfig().setEnableSeqSpaceCompaction(false);
-
IoTDBDescriptor.getInstance().getConfig().setEnableUnseqSpaceCompaction(false);
-
IoTDBDescriptor.getInstance().getConfig().setEnableCrossSpaceCompaction(false);
- TSFileDescriptor.getInstance().getConfig().setMaxNumberOfPointsInPage(3);
- AlignedWriteUtil.insertData();
- }
-
- @AfterClass
- public static void tearDown() throws Exception {
-
IoTDBDescriptor.getInstance().getConfig().setEnableSeqSpaceCompaction(enableSeqSpaceCompaction);
- IoTDBDescriptor.getInstance()
- .getConfig()
- .setEnableUnseqSpaceCompaction(enableUnseqSpaceCompaction);
- IoTDBDescriptor.getInstance()
- .getConfig()
- .setEnableCrossSpaceCompaction(enableCrossSpaceCompaction);
-
TSFileDescriptor.getInstance().getConfig().setMaxNumberOfPointsInPage(numOfPointsPerPage);
- EnvironmentUtils.cleanEnv();
- }
-}
diff --git
a/integration/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBAggregationWithValueFilterIT.java
b/integration/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBAggregationWithValueFilterIT.java
deleted file mode 100644
index 77aa1dca85..0000000000
---
a/integration/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBAggregationWithValueFilterIT.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * 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.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.itbase.category.LocalStandaloneTest;
-import org.apache.iotdb.jdbc.Config;
-
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-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.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-@Category({LocalStandaloneTest.class})
-public class IoTDBAggregationWithValueFilterIT {
-
- private static final double DELTA = 1e-6;
- protected static boolean enableSeqSpaceCompaction;
- protected static boolean enableUnseqSpaceCompaction;
- protected static boolean enableCrossSpaceCompaction;
-
- @BeforeClass
- public static void setUp() throws Exception {
- EnvironmentUtils.envSetUp();
- // TODO When the aligned time series support compaction, we need to set
compaction to true
- enableSeqSpaceCompaction =
- IoTDBDescriptor.getInstance().getConfig().isEnableSeqSpaceCompaction();
- enableUnseqSpaceCompaction =
-
IoTDBDescriptor.getInstance().getConfig().isEnableUnseqSpaceCompaction();
- enableCrossSpaceCompaction =
-
IoTDBDescriptor.getInstance().getConfig().isEnableCrossSpaceCompaction();
-
IoTDBDescriptor.getInstance().getConfig().setEnableSeqSpaceCompaction(false);
-
IoTDBDescriptor.getInstance().getConfig().setEnableUnseqSpaceCompaction(false);
-
IoTDBDescriptor.getInstance().getConfig().setEnableCrossSpaceCompaction(false);
- AlignedWriteUtil.insertData();
- }
-
- @AfterClass
- public static void tearDown() throws Exception {
-
IoTDBDescriptor.getInstance().getConfig().setEnableSeqSpaceCompaction(enableSeqSpaceCompaction);
- IoTDBDescriptor.getInstance()
- .getConfig()
- .setEnableUnseqSpaceCompaction(enableUnseqSpaceCompaction);
- IoTDBDescriptor.getInstance()
- .getConfig()
- .setEnableCrossSpaceCompaction(enableCrossSpaceCompaction);
- EnvironmentUtils.cleanEnv();
- }
-
- @Test
- public void countAlignedWithValueFilterTest() throws ClassNotFoundException {
- String[] retArray = new String[] {"11"};
- String[] columnNames = {"count(root.sg1.d1.s4)"};
- 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 count(s4) from
root.sg1.d1 where s4 = true");
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
- Map<String, Integer> map = new HashMap<>(); // used to adjust result
sequence
- for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
- map.put(resultSetMetaData.getColumnName(i), i);
- }
- assertEquals(columnNames.length, resultSetMetaData.getColumnCount());
- int cnt = 0;
- while (resultSet.next()) {
- String[] ans = new String[columnNames.length];
- // No need to add time column for aggregation query
- for (int i = 0; i < columnNames.length; i++) {
- String columnName = columnNames[i];
- int index = map.get(columnName);
- ans[i] = resultSet.getString(index);
- }
- assertArrayEquals(retArray, ans);
- cnt++;
- }
- assertEquals(1, cnt);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void aggregationFuncAlignedWithValueFilterTest() throws
ClassNotFoundException {
- String[] retArray = new String[] {"8", "42.0", "5.25", "1.0", "9.0", "1",
"9", "1.0", "9.0"};
- String[] columnNames = {
- "count(root.sg1.d1.s1)",
- "sum(root.sg1.d1.s1)",
- "avg(root.sg1.d1.s1)",
- "first_value(root.sg1.d1.s1)",
- "last_value(root.sg1.d1.s1)",
- "min_time(root.sg1.d1.s1)",
- "max_time(root.sg1.d1.s1)",
- "min_value(root.sg1.d1.s1)",
- "max_value(root.sg1.d1.s1)",
- };
- 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 count(s1), sum(s1), avg(s1), "
- + "first_value(s1), last_value(s1), "
- + "min_time(s1), max_time(s1),"
- + "max_value(s1), min_value(s1) from root.sg1.d1 where s1 <
10");
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
- Map<String, Integer> map = new HashMap<>(); // used to adjust result
sequence
- for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
- map.put(resultSetMetaData.getColumnName(i), i);
- }
- assertEquals(columnNames.length, resultSetMetaData.getColumnCount());
- int cnt = 0;
- while (resultSet.next()) {
- String[] ans = new String[columnNames.length];
- // No need to add time column for aggregation query
- for (int i = 0; i < columnNames.length; i++) {
- String columnName = columnNames[i];
- int index = map.get(columnName);
- ans[i] = resultSet.getString(index);
- }
- assertArrayEquals(retArray, ans);
- cnt++;
- }
- assertEquals(1, cnt);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void countAllAlignedWithValueFilterTest() throws
ClassNotFoundException {
- String[] retArray = new String[] {"6", "6", "9", "11", "6"};
- String[] columnNames = {
- "count(root.sg1.d1.s1)",
- "count(root.sg1.d1.s2)",
- "count(root.sg1.d1.s3)",
- "count(root.sg1.d1.s4)",
- "count(root.sg1.d1.s5)"
- };
- 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 count(*) from
root.sg1.d1 where s4 = true");
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
- Map<String, Integer> map = new HashMap<>(); // used to adjust result
sequence
- for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
- map.put(resultSetMetaData.getColumnName(i), i);
- }
- assertEquals(columnNames.length, resultSetMetaData.getColumnCount());
- int cnt = 0;
- while (resultSet.next()) {
- String[] ans = new String[columnNames.length];
- // No need to add time column for aggregation query
- for (int i = 0; i < columnNames.length; i++) {
- String columnName = columnNames[i];
- int index = map.get(columnName);
- ans[i] = resultSet.getString(index);
- }
- assertArrayEquals(retArray, ans);
- cnt++;
- }
- assertEquals(1, cnt);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void aggregationAllAlignedWithValueFilterTest() throws
ClassNotFoundException {
- String[] retArray = new String[] {"160016.0", "11", "1", "13"};
- String[] columnNames = {
- "sum(root.sg1.d1.s1)",
- "count(root.sg1.d1.s4)",
- "min_value(root.sg1.d1.s3)",
- "max_time(root.sg1.d1.s2)",
- };
- 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 sum(s1), count(s4), min_value(s3), max_time(s2) from
root.sg1.d1 where s4 = true");
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
- Map<String, Integer> map = new HashMap<>(); // used to adjust result
sequence
- for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
- map.put(resultSetMetaData.getColumnName(i), i);
- }
- assertEquals(columnNames.length, resultSetMetaData.getColumnCount());
- int cnt = 0;
- while (resultSet.next()) {
- String[] ans = new String[columnNames.length];
- // No need to add time column for aggregation query
- for (int i = 0; i < columnNames.length; i++) {
- String columnName = columnNames[i];
- int index = map.get(columnName);
- ans[i] = resultSet.getString(index);
- }
- assertArrayEquals(retArray, ans);
- cnt++;
- }
- assertEquals(1, cnt);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-}
diff --git
a/integration/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBAggregationWithValueFilterWithDeletion2IT.java
b/integration/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBAggregationWithValueFilterWithDeletion2IT.java
deleted file mode 100644
index 4268b5ccb4..0000000000
---
a/integration/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBAggregationWithValueFilterWithDeletion2IT.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.itbase.category.LocalStandaloneTest;
-import org.apache.iotdb.jdbc.Config;
-import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.experimental.categories.Category;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.Statement;
-
-@Category({LocalStandaloneTest.class})
-/** Let One chunk has more than one page. */
-public class IoTDBAggregationWithValueFilterWithDeletion2IT
- extends IoTDBAggregationWithValueFilterWithDeletionIT {
-
- private static int numOfPointsPerPage;
-
- @BeforeClass
- public static void setUp() throws Exception {
- EnvironmentUtils.envSetUp();
-
- enableSeqSpaceCompaction =
- IoTDBDescriptor.getInstance().getConfig().isEnableSeqSpaceCompaction();
- enableUnseqSpaceCompaction =
-
IoTDBDescriptor.getInstance().getConfig().isEnableUnseqSpaceCompaction();
- enableCrossSpaceCompaction =
-
IoTDBDescriptor.getInstance().getConfig().isEnableCrossSpaceCompaction();
- numOfPointsPerPage =
TSFileDescriptor.getInstance().getConfig().getMaxNumberOfPointsInPage();
-
IoTDBDescriptor.getInstance().getConfig().setEnableSeqSpaceCompaction(false);
-
IoTDBDescriptor.getInstance().getConfig().setEnableUnseqSpaceCompaction(false);
-
IoTDBDescriptor.getInstance().getConfig().setEnableCrossSpaceCompaction(false);
- TSFileDescriptor.getInstance().getConfig().setMaxNumberOfPointsInPage(3);
- AlignedWriteUtil.insertData();
- 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()) {
- // TODO currently aligned data in memory doesn't support deletion, so we
flush all data to
- // disk before doing deletion
- statement.execute("flush");
- statement.execute("delete timeseries root.sg1.d1.s2");
- statement.execute("delete from root.sg1.d1.s1 where time <= 21");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @AfterClass
- public static void tearDown() throws Exception {
-
IoTDBDescriptor.getInstance().getConfig().setEnableSeqSpaceCompaction(enableSeqSpaceCompaction);
- IoTDBDescriptor.getInstance()
- .getConfig()
- .setEnableUnseqSpaceCompaction(enableUnseqSpaceCompaction);
- IoTDBDescriptor.getInstance()
- .getConfig()
- .setEnableCrossSpaceCompaction(enableCrossSpaceCompaction);
-
TSFileDescriptor.getInstance().getConfig().setMaxNumberOfPointsInPage(numOfPointsPerPage);
- EnvironmentUtils.cleanEnv();
- }
-}
diff --git
a/integration/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBAggregationWithValueFilterWithDeletionIT.java
b/integration/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBAggregationWithValueFilterWithDeletionIT.java
deleted file mode 100644
index ea7782467d..0000000000
---
a/integration/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBAggregationWithValueFilterWithDeletionIT.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * 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.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.itbase.category.LocalStandaloneTest;
-import org.apache.iotdb.jdbc.Config;
-
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-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.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-@Category({LocalStandaloneTest.class})
-public class IoTDBAggregationWithValueFilterWithDeletionIT {
-
- private static final double DELTA = 1e-6;
- protected static boolean enableSeqSpaceCompaction;
- protected static boolean enableUnseqSpaceCompaction;
- protected static boolean enableCrossSpaceCompaction;
-
- @BeforeClass
- public static void setUp() throws Exception {
- EnvironmentUtils.envSetUp();
-
- enableSeqSpaceCompaction =
- IoTDBDescriptor.getInstance().getConfig().isEnableSeqSpaceCompaction();
- enableUnseqSpaceCompaction =
-
IoTDBDescriptor.getInstance().getConfig().isEnableUnseqSpaceCompaction();
- enableCrossSpaceCompaction =
-
IoTDBDescriptor.getInstance().getConfig().isEnableCrossSpaceCompaction();
-
IoTDBDescriptor.getInstance().getConfig().setEnableSeqSpaceCompaction(false);
-
IoTDBDescriptor.getInstance().getConfig().setEnableUnseqSpaceCompaction(false);
-
IoTDBDescriptor.getInstance().getConfig().setEnableCrossSpaceCompaction(false);
-
- AlignedWriteUtil.insertData();
- 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()) {
- // TODO currently aligned data in memory doesn't support deletion, so we
flush all data to
- // disk before doing deletion
- statement.execute("flush");
- statement.execute("delete timeseries root.sg1.d1.s2");
- statement.execute("delete from root.sg1.d1.s1 where time <= 21");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @AfterClass
- public static void tearDown() throws Exception {
-
IoTDBDescriptor.getInstance().getConfig().setEnableSeqSpaceCompaction(enableSeqSpaceCompaction);
- IoTDBDescriptor.getInstance()
- .getConfig()
- .setEnableUnseqSpaceCompaction(enableUnseqSpaceCompaction);
- IoTDBDescriptor.getInstance()
- .getConfig()
- .setEnableCrossSpaceCompaction(enableCrossSpaceCompaction);
- EnvironmentUtils.cleanEnv();
- }
-
- @Test
- public void countAlignedWithValueFilterTest() throws ClassNotFoundException {
- String[] retArray = new String[] {"11"};
- String[] columnNames = {"count(root.sg1.d1.s4)"};
- 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 count(s4) from
root.sg1.d1 where s4 = true");
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
- Map<String, Integer> map = new HashMap<>(); // used to adjust result
sequence
- for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
- map.put(resultSetMetaData.getColumnName(i), i);
- }
- assertEquals(columnNames.length, resultSetMetaData.getColumnCount());
- int cnt = 0;
- while (resultSet.next()) {
- String[] ans = new String[columnNames.length];
- // No need to add time column for aggregation query
- for (int i = 0; i < columnNames.length; i++) {
- String columnName = columnNames[i];
- int index = map.get(columnName);
- ans[i] = resultSet.getString(index);
- }
- assertArrayEquals(retArray, ans);
- cnt++;
- }
- assertEquals(1, cnt);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void countAllAlignedWithValueFilterTest() throws
ClassNotFoundException {
- String[] retArray = new String[] {"0", "9", "11", "6"};
- String[] columnNames = {
- "count(root.sg1.d1.s1)",
- "count(root.sg1.d1.s3)",
- "count(root.sg1.d1.s4)",
- "count(root.sg1.d1.s5)"
- };
- 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 count(*) from
root.sg1.d1 where s4 = true");
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
- Map<String, Integer> map = new HashMap<>(); // used to adjust result
sequence
- for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
- map.put(resultSetMetaData.getColumnName(i), i);
- }
- assertEquals(columnNames.length, resultSetMetaData.getColumnCount());
- int cnt = 0;
- while (resultSet.next()) {
- String[] ans = new String[columnNames.length];
- // No need to add time column for aggregation query
- for (int i = 0; i < columnNames.length; i++) {
- String columnName = columnNames[i];
- int index = map.get(columnName);
- ans[i] = resultSet.getString(index);
- }
- assertArrayEquals(retArray, ans);
- cnt++;
- }
- assertEquals(1, cnt);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void aggregationAllAlignedWithValueFilterTest() throws
ClassNotFoundException {
- String[] retArray = new String[] {"0", "25", "1"};
- String[] columnNames = {
- "count(root.sg1.d1.s1)", "max_time(root.sg1.d1.s4)",
"min_value(root.sg1.d1.s3)",
- };
- 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 count(s1), max_time(s4), min_value(s3) from root.sg1.d1
where s4 = true");
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
- Map<String, Integer> map = new HashMap<>(); // used to adjust result
sequence
- for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
- map.put(resultSetMetaData.getColumnName(i), i);
- }
- assertEquals(columnNames.length, resultSetMetaData.getColumnCount());
- int cnt = 0;
- while (resultSet.next()) {
- String[] ans = new String[columnNames.length];
- // No need to add time column for aggregation query
- for (int i = 0; i < columnNames.length; i++) {
- String columnName = columnNames[i];
- int index = map.get(columnName);
- ans[i] = resultSet.getString(index);
- }
- assertArrayEquals(retArray, ans);
- cnt++;
- }
- assertEquals(1, cnt);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-}