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 2021/12/29 14:51:36 UTC
[iotdb] branch master updated: [IOTDB-2224] Accelerate tests by using batch insert (#4657)
This is an automated email from the ASF dual-hosted git repository.
haonan 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 1c58407 [IOTDB-2224] Accelerate tests by using batch insert (#4657)
1c58407 is described below
commit 1c5840769bfb58fec555294c0e78cea37d1cd744
Author: BaiJian <er...@hotmail.com>
AuthorDate: Wed Dec 29 22:51:04 2021 +0800
[IOTDB-2224] Accelerate tests by using batch insert (#4657)
* [IOTDB-2224] Accelerate tests by using batch insert
* Remove deprecated test case
---
.../mult/AssignPathManagedMergeReaderTest.java | 3 +-
.../reader/mult/RemoteMultSeriesReaderTest.java | 3 +-
.../cluster/server/member/DataGroupMemberTest.java | 5 ++
.../iotdb/db/integration/IoTDBDeletionIT.java | 6 +-
.../apache/iotdb/db/integration/IoTDBMergeIT.java | 24 ++++--
.../iotdb/db/integration/IoTDBMultiDeviceIT.java | 75 +++++++++---------
.../iotdb/db/integration/IoTDBRestartIT.java | 55 --------------
.../db/integration/aligned/IoTDBDeletionIT.java | 88 ++++++++--------------
.../iotdb/session/IoTDBSessionVectorInsertIT.java | 4 -
.../tsfile/encoding/decoder/IntRleDecoderTest.java | 7 +-
.../regular/RegularDataEncoderLongTest.java | 4 +-
11 files changed, 102 insertions(+), 172 deletions(-)
diff --git a/cluster/src/test/java/org/apache/iotdb/cluster/query/reader/mult/AssignPathManagedMergeReaderTest.java b/cluster/src/test/java/org/apache/iotdb/cluster/query/reader/mult/AssignPathManagedMergeReaderTest.java
index 50f139f..1cce03c 100644
--- a/cluster/src/test/java/org/apache/iotdb/cluster/query/reader/mult/AssignPathManagedMergeReaderTest.java
+++ b/cluster/src/test/java/org/apache/iotdb/cluster/query/reader/mult/AssignPathManagedMergeReaderTest.java
@@ -164,9 +164,8 @@ public class AssignPathManagedMergeReaderTest {
stringByteBufferMap.put(
paths.get(i), generateByteBuffer(batchData.get(i)));
}
-
- resultHandler.onComplete(stringByteBufferMap);
}
+ resultHandler.onComplete(stringByteBufferMap);
})
.start();
}
diff --git a/cluster/src/test/java/org/apache/iotdb/cluster/query/reader/mult/RemoteMultSeriesReaderTest.java b/cluster/src/test/java/org/apache/iotdb/cluster/query/reader/mult/RemoteMultSeriesReaderTest.java
index 8ea7439..210d0db 100644
--- a/cluster/src/test/java/org/apache/iotdb/cluster/query/reader/mult/RemoteMultSeriesReaderTest.java
+++ b/cluster/src/test/java/org/apache/iotdb/cluster/query/reader/mult/RemoteMultSeriesReaderTest.java
@@ -232,9 +232,8 @@ public class RemoteMultSeriesReaderTest {
stringByteBufferMap.put(
paths.get(i), generateByteBuffer(batchData.get(i)));
}
-
- resultHandler.onComplete(stringByteBufferMap);
}
+ resultHandler.onComplete(stringByteBufferMap);
})
.start();
}
diff --git a/cluster/src/test/java/org/apache/iotdb/cluster/server/member/DataGroupMemberTest.java b/cluster/src/test/java/org/apache/iotdb/cluster/server/member/DataGroupMemberTest.java
index 6ff693f..21fec80 100644
--- a/cluster/src/test/java/org/apache/iotdb/cluster/server/member/DataGroupMemberTest.java
+++ b/cluster/src/test/java/org/apache/iotdb/cluster/server/member/DataGroupMemberTest.java
@@ -61,6 +61,7 @@ import org.apache.iotdb.cluster.server.handlers.caller.PullSnapshotHandler;
import org.apache.iotdb.cluster.server.handlers.caller.PullTimeseriesSchemaHandler;
import org.apache.iotdb.cluster.server.service.DataAsyncService;
import org.apache.iotdb.cluster.utils.Constants;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.engine.StorageEngine;
import org.apache.iotdb.db.engine.modification.Deletion;
import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
@@ -134,12 +135,15 @@ public class DataGroupMemberTest extends BaseMember {
private boolean enableSyncLeader;
private int prevReplicationNum;
private int raftId = 0;
+ private boolean enableInflux;
@Override
@Before
public void setUp() throws Exception {
prevReplicationNum = ClusterDescriptor.getInstance().getConfig().getReplicationNum();
ClusterDescriptor.getInstance().getConfig().setReplicationNum(3);
+ enableInflux = IoTDBDescriptor.getInstance().getConfig().isEnableInfluxDBRpcService();
+ IoTDBDescriptor.getInstance().getConfig().setEnableInfluxDBRpcService(false);
super.setUp();
dataGroupMember = getDataGroupMember(TestUtils.getNode(0));
snapshotMap = new HashMap<>();
@@ -158,6 +162,7 @@ public class DataGroupMemberTest extends BaseMember {
dataGroupMember.stop();
super.tearDown();
ClusterDescriptor.getInstance().getConfig().setReplicationNum(prevReplicationNum);
+ IoTDBDescriptor.getInstance().getConfig().setEnableInfluxDBRpcService(enableInflux);
}
private PartitionedSnapshotLogManager getLogManager(
diff --git a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBDeletionIT.java b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBDeletionIT.java
index 932b096..f5b8799 100644
--- a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBDeletionIT.java
+++ b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBDeletionIT.java
@@ -367,16 +367,18 @@ public class IoTDBDeletionIT {
Statement statement = connection.createStatement()) {
for (int i = 1; i <= 100000; i++) {
- statement.execute(
+ statement.addBatch(
String.format(insertTemplate, i, i, i, (double) i, "'" + i + "'", i % 2 == 0));
}
+ statement.executeBatch();
statement.execute("DELETE FROM root.vehicle.d0.s0 WHERE time > 15000 and time <= 30000");
statement.execute("DELETE FROM root.vehicle.d0.s0 WHERE time > 30000 and time <= 40000");
for (int i = 100001; i <= 200000; i++) {
- statement.execute(
+ statement.addBatch(
String.format(insertTemplate, i, i, i, (double) i, "'" + i + "'", i % 2 == 0));
}
+ statement.executeBatch();
statement.execute("DELETE FROM root.vehicle.d0.s0 WHERE time > 50000 and time <= 80000");
statement.execute("DELETE FROM root.vehicle.d0.s0 WHERE time > 90000 and time <= 110000");
statement.execute("DELETE FROM root.vehicle.d0.s0 WHERE time > 150000 and time <= 165000");
diff --git a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBMergeIT.java b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBMergeIT.java
index 895ed2c..7d26be5 100644
--- a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBMergeIT.java
+++ b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBMergeIT.java
@@ -126,18 +126,20 @@ public class IoTDBMergeIT {
for (int i = 0; i < 10; i++) {
logger.info("Running the {} round merge", i);
for (int j = i * 10 + 1; j <= (i + 1) * 10; j++) {
- statement.execute(
+ statement.addBatch(
String.format(
"INSERT INTO root.mergeTest(timestamp,s1,s2,s3) VALUES (%d,%d," + "%d,%d)",
j, j + 1, j + 2, j + 3));
}
+ statement.executeBatch();
statement.execute("FLUSH");
for (int j = i * 10 + 1; j <= (i + 1) * 10; j++) {
- statement.execute(
+ statement.addBatch(
String.format(
"INSERT INTO root.mergeTest(timestamp,s1,s2,s3) VALUES (%d,%d," + "%d,%d)",
j, j + 10, j + 20, j + 30));
}
+ statement.executeBatch();
statement.execute("FLUSH");
try {
Thread.sleep(1000);
@@ -185,33 +187,37 @@ public class IoTDBMergeIT {
}
for (int j = 10; j < 20; j++) {
- statement.execute(
+ statement.addBatch(
String.format(
"INSERT INTO root.mergeTest(timestamp,s1,s2,s3) VALUES (%d,%d," + "%d,%d)",
j, j + 1, j + 2, j + 3));
}
+ statement.executeBatch();
statement.execute("FLUSH");
for (int j = 20; j < 30; j++) {
- statement.execute(
+ statement.addBatch(
String.format(
"INSERT INTO root.mergeTest(timestamp,s1,s2,s3) VALUES (%d,%d," + "%d,%d)",
j, j + 1, j + 2, j + 3));
}
+ statement.executeBatch();
statement.execute("FLUSH");
for (int j = 20; j < 30; j++) {
- statement.execute(
+ statement.addBatch(
String.format(
"INSERT INTO root.mergeTest(timestamp,s1,s2,s3) VALUES (%d,%d," + "%d,%d)",
j, j + 10, j + 20, j + 30));
}
+ statement.executeBatch();
statement.execute("FLUSH");
for (int j = 10; j < 20; j++) {
- statement.execute(
+ statement.addBatch(
String.format(
"INSERT INTO root.mergeTest(timestamp,s1,s2,s3) VALUES (%d,%d," + "%d,%d)",
j, j + 10, j + 20, j + 30));
}
+ statement.executeBatch();
statement.execute("FLUSH");
statement.execute("MERGE");
@@ -267,19 +273,21 @@ public class IoTDBMergeIT {
for (int i = 0; i < 10; i++) {
// sequence files
for (int j = i * 1000 + 300 + k * 100; j <= i * 1000 + 399 + k * 100; j++) {
- statement.execute(
+ statement.addBatch(
String.format(
"INSERT INTO root.mergeTest(timestamp,s1,s2,s3) VALUES (%d,%d," + "%d,%d)",
j, j + 1, j + 2, j + 3));
}
+ statement.executeBatch();
statement.execute("FLUSH");
// unsequence files
for (int j = i * 1000 + k * 100; j <= i * 1000 + 99 + k * 100; j++) {
- statement.execute(
+ statement.addBatch(
String.format(
"INSERT INTO root.mergeTest(timestamp,s1,s2,s3) VALUES (%d,%d," + "%d,%d)",
j, j + 10, j + 20, j + 30));
}
+ statement.executeBatch();
statement.execute("FLUSH");
}
}
diff --git a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBMultiDeviceIT.java b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBMultiDeviceIT.java
index c102d42..6a77c28 100644
--- a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBMultiDeviceIT.java
+++ b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBMultiDeviceIT.java
@@ -111,69 +111,72 @@ public class IoTDBMultiDeviceIT {
String sql =
String.format("insert into root.fans.d0(timestamp,s0) values(%s,%s)", time, time % 70);
- statement.execute(sql);
+ statement.addBatch(sql);
sql =
String.format("insert into root.fans.d1(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
sql =
String.format("insert into root.fans.d2(timestamp,s0) values(%s,%s)", time, time % 70);
- statement.execute(sql);
+ statement.addBatch(sql);
sql =
String.format("insert into root.fans.d3(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
sql = String.format("insert into root.car.d0(timestamp,s0) values(%s,%s)", time, time % 70);
- statement.execute(sql);
+ statement.addBatch(sql);
sql = String.format("insert into root.car.d1(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
sql = String.format("insert into root.car.d2(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
}
+ statement.executeBatch();
// insert large amount of data time range : 13700 ~ 24000
for (int time = 13700; time < 24000; time++) {
String sql =
String.format("insert into root.fans.d0(timestamp,s0) values(%s,%s)", time, time % 70);
- statement.execute(sql);
+ statement.addBatch(sql);
sql =
String.format("insert into root.fans.d1(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
sql =
String.format("insert into root.fans.d2(timestamp,s0) values(%s,%s)", time, time % 70);
- statement.execute(sql);
+ statement.addBatch(sql);
sql =
String.format("insert into root.fans.d3(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
sql = String.format("insert into root.car.d0(timestamp,s0) values(%s,%s)", time, time % 70);
- statement.execute(sql);
+ statement.addBatch(sql);
sql = String.format("insert into root.car.d1(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
sql = String.format("insert into root.car.d2(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
}
+ statement.executeBatch();
// insert large amount of data time range : 3000 ~ 13600
for (int time = 3000; time < 13600; time++) {
// System.out.println("===" + time);
String sql =
String.format("insert into root.fans.d0(timestamp,s0) values(%s,%s)", time, time % 70);
- statement.execute(sql);
+ statement.addBatch(sql);
sql =
String.format("insert into root.fans.d1(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
sql =
String.format("insert into root.fans.d2(timestamp,s0) values(%s,%s)", time, time % 70);
- statement.execute(sql);
+ statement.addBatch(sql);
sql =
String.format("insert into root.fans.d3(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
sql = String.format("insert into root.car.d0(timestamp,s0) values(%s,%s)", time, time % 70);
- statement.execute(sql);
+ statement.addBatch(sql);
sql = String.format("insert into root.car.d1(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
sql = String.format("insert into root.car.d2(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
}
+ statement.executeBatch();
statement.execute("flush");
statement.execute("merge");
@@ -183,46 +186,48 @@ public class IoTDBMultiDeviceIT {
String sql =
String.format("insert into root.fans.d0(timestamp,s0) values(%s,%s)", time, time % 70);
- statement.execute(sql);
+ statement.addBatch(sql);
sql =
String.format("insert into root.fans.d1(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
sql =
String.format("insert into root.fans.d2(timestamp,s0) values(%s,%s)", time, time % 70);
- statement.execute(sql);
+ statement.addBatch(sql);
sql =
String.format("insert into root.fans.d3(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
sql = String.format("insert into root.car.d0(timestamp,s0) values(%s,%s)", time, time % 70);
- statement.execute(sql);
+ statement.addBatch(sql);
sql = String.format("insert into root.car.d1(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
sql = String.format("insert into root.car.d2(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
}
+ statement.executeBatch();
// sequential data, memory data
for (int time = 200000; time < 201000; time++) {
String sql =
String.format("insert into root.fans.d0(timestamp,s0) values(%s,%s)", time, time % 70);
- statement.execute(sql);
+ statement.addBatch(sql);
sql =
String.format("insert into root.fans.d1(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
sql =
String.format("insert into root.fans.d2(timestamp,s0) values(%s,%s)", time, time % 70);
- statement.execute(sql);
+ statement.addBatch(sql);
sql =
String.format("insert into root.fans.d3(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
sql = String.format("insert into root.car.d0(timestamp,s0) values(%s,%s)", time, time % 70);
- statement.execute(sql);
+ statement.addBatch(sql);
sql = String.format("insert into root.car.d1(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
sql = String.format("insert into root.car.d2(timestamp,s0) values(%s,%s)", time, time % 40);
- statement.execute(sql);
+ statement.addBatch(sql);
}
+ statement.executeBatch();
} catch (Exception e) {
e.printStackTrace();
diff --git a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBRestartIT.java b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBRestartIT.java
index 8b2fcec..b835a65 100644
--- a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBRestartIT.java
+++ b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBRestartIT.java
@@ -21,7 +21,6 @@ package org.apache.iotdb.db.integration;
import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.engine.StorageEngine;
-import org.apache.iotdb.db.engine.compaction.CompactionTaskManager;
import org.apache.iotdb.db.exception.StorageEngineException;
import org.apache.iotdb.db.utils.EnvironmentUtils;
import org.apache.iotdb.itbase.category.LocalStandaloneTest;
@@ -405,58 +404,4 @@ public class IoTDBRestartIT {
config.setUnSeqTsFileSize(unFsFileSize);
EnvironmentUtils.cleanEnv();
}
-
- @Test
- public void testRestartCompaction()
- throws SQLException, ClassNotFoundException, IOException, StorageEngineException {
- EnvironmentUtils.envSetUp();
- 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()) {
- statement.execute("insert into root.turbine.d1(timestamp,s1) values(2,1.0)");
- statement.execute("flush");
- statement.execute("insert into root.turbine.d1(timestamp,s1) values(3,1.0)");
- statement.execute("flush");
- statement.execute("insert into root.turbine.d1(timestamp,s1) values(4,1.0)");
- statement.execute("flush");
- statement.execute("insert into root.turbine.d1(timestamp,s1) values(5,1.0)");
- statement.execute("flush");
- statement.execute("insert into root.turbine.d1(timestamp,s1) values(6,1.0)");
- statement.execute("flush");
- statement.execute("insert into root.turbine.d1(timestamp,s1) values(1,1.0)");
- statement.execute("flush");
- statement.execute("insert into root.turbine.d1(timestamp,s1) values(7,1.0)");
- statement.execute("flush");
- }
-
- try {
- CompactionTaskManager.getInstance().waitAllCompactionFinish();
- Thread.sleep(10000);
- EnvironmentUtils.restartDaemon();
- } catch (Exception e) {
- Assert.fail();
- }
-
- 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 s1 FROM root.turbine.d1");
- assertTrue(hasResultSet);
- String[] exp = new String[] {"1,1.0", "2,1.0", "3,1.0", "4,1.0", "5,1.0", "6,1.0", "7,1.0"};
- int cnt = 0;
- try (ResultSet resultSet = statement.getResultSet()) {
- while (resultSet.next()) {
- String result = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(2);
- assertEquals(exp[cnt], result);
- cnt++;
- }
- }
- }
-
- EnvironmentUtils.cleanEnv();
- }
}
diff --git a/integration/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBDeletionIT.java b/integration/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBDeletionIT.java
index 80110b9..2e245c6 100644
--- a/integration/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBDeletionIT.java
+++ b/integration/src/test/java/org/apache/iotdb/db/integration/aligned/IoTDBDeletionIT.java
@@ -20,9 +20,9 @@
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.integration.env.ConfigFactory;
+import org.apache.iotdb.integration.env.EnvFactory;
import org.apache.iotdb.itbase.category.LocalStandaloneTest;
-import org.apache.iotdb.jdbc.Config;
import org.junit.After;
import org.junit.Assert;
@@ -32,7 +32,6 @@ 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.SQLException;
import java.sql.Statement;
@@ -60,18 +59,16 @@ public class IoTDBDeletionIT {
@Before
public void setUp() throws Exception {
Locale.setDefault(Locale.ENGLISH);
- EnvironmentUtils.closeStatMonitor();
prevPartitionInterval = IoTDBDescriptor.getInstance().getConfig().getPartitionInterval();
- IoTDBDescriptor.getInstance().getConfig().setPartitionInterval(1000);
- EnvironmentUtils.envSetUp();
- Class.forName(Config.JDBC_DRIVER_NAME);
+ ConfigFactory.getConfig().setPartitionInterval(1000);
+ EnvFactory.getEnv().initBeforeTest();
prepareSeries();
}
@After
public void tearDown() throws Exception {
- EnvironmentUtils.cleanEnv();
- IoTDBDescriptor.getInstance().getConfig().setPartitionInterval(prevPartitionInterval);
+ EnvFactory.getEnv().cleanAfterTest();
+ ConfigFactory.getConfig().setPartitionInterval(prevPartitionInterval);
}
/**
@@ -81,9 +78,7 @@ public class IoTDBDeletionIT {
*/
@Test
public void testUnsupportedValueFilter() throws SQLException {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute("insert into root.vehicle.d0(time,s0) aligned values (10,310)");
@@ -157,9 +152,7 @@ public class IoTDBDeletionIT {
@Test
public void test() throws SQLException {
prepareData();
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute("DELETE FROM root.vehicle.d0.s0 WHERE time <= 300");
@@ -200,9 +193,7 @@ public class IoTDBDeletionIT {
public void testMerge() throws SQLException {
prepareMerge();
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute("merge");
statement.execute("DELETE FROM root.vehicle.d0.** WHERE time <= 15000");
@@ -230,9 +221,7 @@ public class IoTDBDeletionIT {
@Test
public void testDelAfterFlush() throws SQLException {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute("SET STORAGE GROUP TO root.ln.wf01.wt01");
statement.execute(
@@ -254,9 +243,7 @@ public class IoTDBDeletionIT {
@Test
public void testRangeDelete() throws SQLException {
prepareData();
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute("DELETE FROM root.vehicle.d0.s0 WHERE time <= 300");
@@ -291,9 +278,7 @@ public class IoTDBDeletionIT {
@Test
public void testFullDeleteWithoutWhereClause() throws SQLException {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute("DELETE FROM root.vehicle.d0.s0");
try (ResultSet set = statement.executeQuery("SELECT s0 FROM root.vehicle.d0")) {
@@ -310,9 +295,7 @@ public class IoTDBDeletionIT {
@Test
public void testPartialPathRangeDelete() throws SQLException {
prepareData();
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute("DELETE FROM root.vehicle.d0.* WHERE time <= 300 and time > 150");
@@ -341,16 +324,14 @@ public class IoTDBDeletionIT {
long size = IoTDBDescriptor.getInstance().getConfig().getMemtableSizeThreshold();
// Adjust memstable threshold size to make it flush automatically
IoTDBDescriptor.getInstance().getConfig().setMemtableSizeThreshold(10000);
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
for (int i = 1; i <= 10000; i++) {
- statement.execute(
+ statement.addBatch(
String.format(insertTemplate, i, i, i, (double) i, "'" + i + "'", i % 2 == 0));
}
-
+ statement.executeBatch();
statement.execute("DELETE FROM root.vehicle.d0.s0 WHERE time > 1500 and time <= 9000");
try (ResultSet set = statement.executeQuery("SELECT s0 FROM root.vehicle.d0")) {
int cnt = 0;
@@ -369,22 +350,21 @@ public class IoTDBDeletionIT {
long size = IoTDBDescriptor.getInstance().getConfig().getMemtableSizeThreshold();
// Adjust memstable threshold size to make it flush automatically
IoTDBDescriptor.getInstance().getConfig().setMemtableSizeThreshold(1000000);
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
for (int i = 1; i <= 100000; i++) {
- statement.execute(
+ statement.addBatch(
String.format(insertTemplate, i, i, i, (double) i, "'" + i + "'", i % 2 == 0));
}
-
+ statement.executeBatch();
statement.execute("DELETE FROM root.vehicle.d0.s0 WHERE time > 15000 and time <= 30000");
statement.execute("DELETE FROM root.vehicle.d0.s0 WHERE time > 30000 and time <= 40000");
for (int i = 100001; i <= 200000; i++) {
- statement.execute(
+ statement.addBatch(
String.format(insertTemplate, i, i, i, (double) i, "'" + i + "'", i % 2 == 0));
}
+ statement.executeBatch();
statement.execute("DELETE FROM root.vehicle.d0.s0 WHERE time > 50000 and time <= 80000");
statement.execute("DELETE FROM root.vehicle.d0.s0 WHERE time > 90000 and time <= 110000");
statement.execute("DELETE FROM root.vehicle.d0.s0 WHERE time > 150000 and time <= 165000");
@@ -403,9 +383,7 @@ public class IoTDBDeletionIT {
@Test
public void testDelSeriesWithSpecialSymbol() throws SQLException {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute(
"CREATE TIMESERIES root.ln.d1.`\"status,01\"` WITH DATATYPE=BOOLEAN, ENCODING=PLAIN");
@@ -444,9 +422,7 @@ public class IoTDBDeletionIT {
private static void prepareSeries() {
String sq = null;
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
for (String sql : creationSqls) {
@@ -460,9 +436,7 @@ public class IoTDBDeletionIT {
}
private void prepareData() throws SQLException {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
// prepare BufferWrite file
@@ -493,30 +467,28 @@ public class IoTDBDeletionIT {
}
private void cleanData() throws SQLException {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute(deleteAllTemplate);
}
}
public void prepareMerge() throws SQLException {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
// prepare BufferWrite data
for (int i = 10001; i <= 20000; i++) {
- statement.execute(
+ statement.addBatch(
String.format(insertTemplate, i, i, i, (double) i, "'" + i + "'", i % 2 == 0));
}
+ statement.executeBatch();
// prepare Overflow data
for (int i = 1; i <= 10000; i++) {
- statement.execute(
+ statement.addBatch(
String.format(insertTemplate, i, i, i, (double) i, "'" + i + "'", i % 2 == 0));
}
+ statement.executeBatch();
}
}
}
diff --git a/session/src/test/java/org/apache/iotdb/session/IoTDBSessionVectorInsertIT.java b/session/src/test/java/org/apache/iotdb/session/IoTDBSessionVectorInsertIT.java
index 808a79b..4e68108 100644
--- a/session/src/test/java/org/apache/iotdb/session/IoTDBSessionVectorInsertIT.java
+++ b/session/src/test/java/org/apache/iotdb/session/IoTDBSessionVectorInsertIT.java
@@ -450,9 +450,6 @@ public class IoTDBSessionVectorInsertIT {
@Test
public void testInsertPartialAlignedTablet()
throws IoTDBConnectionException, StatementExecutionException {
- session = new Session("127.0.0.1", 6667, "root", "root");
- session.open();
-
List<String> multiMeasurementComponents = new ArrayList<>();
for (int i = 1; i <= 3; i++) {
multiMeasurementComponents.add("s" + i);
@@ -515,6 +512,5 @@ public class IoTDBSessionVectorInsertIT {
Assert.assertEquals(1.0, rowRecord.getFields().get(1).getDoubleV(), 0.01);
Assert.assertEquals(null, rowRecord.getFields().get(2).getObjectValue(TSDataType.TEXT));
}
- session.close();
}
}
diff --git a/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/IntRleDecoderTest.java b/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/IntRleDecoderTest.java
index efd73b5..d33a5d6 100644
--- a/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/IntRleDecoderTest.java
+++ b/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/IntRleDecoderTest.java
@@ -58,7 +58,7 @@ public class IntRleDecoderTest {
rleStart *= -3;
}
- bpList = new ArrayList<>();
+ bpList = new ArrayList<>(100000);
int bpCount = 100000;
int bpStart = 11;
for (int i = 0; i < bpCount; i++) {
@@ -70,11 +70,10 @@ public class IntRleDecoderTest {
}
}
- hybridList = new ArrayList<>();
int hybridCount = 11;
int hybridNum = 1000;
int hybridStart = 20;
-
+ hybridList = new ArrayList<>(hybridCount * 2 * hybridNum);
for (int i = 0; i < hybridNum; i++) {
for (int j = 0; j < hybridCount; j++) {
hybridStart += 3;
@@ -100,7 +99,7 @@ public class IntRleDecoderTest {
@Test
public void testRleReadBigInt() throws IOException {
- List<Integer> list = new ArrayList<>();
+ List<Integer> list = new ArrayList<>(3000000);
for (int i = 7000000; i < 10000000; i++) {
list.add(i);
}
diff --git a/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderLongTest.java b/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderLongTest.java
index cb5a885..ebe776e 100644
--- a/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderLongTest.java
+++ b/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/regular/RegularDataEncoderLongTest.java
@@ -211,11 +211,11 @@ public class RegularDataEncoderLongTest {
private List<String> getBetweenDateWithTwoSecond(String start, String end) {
TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
- List<String> list = new ArrayList<>();
LocalDateTime startDate = LocalDateTime.parse(start);
LocalDateTime endDate = LocalDateTime.parse(end);
long distance = ChronoUnit.SECONDS.between(startDate, endDate);
+ List<String> list = new ArrayList<>((int) distance / 2 + 1);
if (distance < 1) {
return list;
}
@@ -240,7 +240,7 @@ public class RegularDataEncoderLongTest {
}
private void shouldReadAndWrite(long[] data, int length) throws IOException {
- out = new ByteArrayOutputStream();
+ out = new ByteArrayOutputStream(data.length * 16);
writeData(data, length);
byte[] page = out.toByteArray();
buffer = ByteBuffer.wrap(page);