You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2021/02/06 11:03:51 UTC

[iotdb] branch master updated: IOTDB-1140 optimize regular data encoding (#2621)

This is an automated email from the ASF dual-hosted git repository.

qiaojialin 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 064cd96  IOTDB-1140 optimize regular data encoding (#2621)
064cd96 is described below

commit 064cd9697bfc5935a9efa896eb079f76b82cec34
Author: wangchao316 <66...@users.noreply.github.com>
AuthorDate: Sat Feb 6 19:03:34 2021 +0800

    IOTDB-1140 optimize regular data encoding (#2621)
---
 docs/UserGuide/Concept/Encoding.md                 |   2 +-
 docs/zh/UserGuide/Concept/Encoding.md              |   2 +-
 .../resources/conf/iotdb-engine.properties         |   4 +-
 .../org/apache/iotdb/db/conf/IoTDBConfigCheck.java |   9 +
 .../org/apache/iotdb/db/utils/SchemaUtils.java     |   1 -
 .../iotdb/db/integration/IoTDBCheckConfigIT.java   | 157 ++++++++++++
 .../iotdb/db/integration/IoTDBEncodingIT.java      | 276 +++++++++++++++++++++
 7 files changed, 446 insertions(+), 5 deletions(-)

diff --git a/docs/UserGuide/Concept/Encoding.md b/docs/UserGuide/Concept/Encoding.md
index 263c04b..28c13d0 100644
--- a/docs/UserGuide/Concept/Encoding.md
+++ b/docs/UserGuide/Concept/Encoding.md
@@ -49,7 +49,7 @@ Usage restrictions: When using GORILLA to encode INT32 data, you need to ensure
 
 * REGULAR
 
-Regular data encoding is more suitable for encoding regular sequence increasing data (e.g. the timeseries with the same time elapsed between each data point), in which case it's better than TS_2DIFF.
+Regular data encoding is more suitable for time encoding regular sequence increasing data (e.g. the timeseries with the same time elapsed between each data point), in which case it's better than TS_2DIFF.
 
 Regular data encoding method is not suitable for the data with fluctuations (irregular data), and TS_2DIFF is recommended to deal with it.
 
diff --git a/docs/zh/UserGuide/Concept/Encoding.md b/docs/zh/UserGuide/Concept/Encoding.md
index 1e0de13..0b868ec 100644
--- a/docs/zh/UserGuide/Concept/Encoding.md
+++ b/docs/zh/UserGuide/Concept/Encoding.md
@@ -49,7 +49,7 @@ GORILLA编码是一种无损编码,它比较适合编码前后值比较接近
 
 * 定频数据编码 (REGULAR)
 
-定频数据编码,仅适用于整形(INT32)和长整型(INT64)的定频数据,且允许数据中有一些点缺失,使用此方法编码定频数据优于二阶差分编码(TS_2DIFF)。
+定频数据编码,仅适用于整形(INT32)和长整型(INT64)的时间列定频数据,且允许数据中有一些点缺失,使用此方法编码定频数据优于二阶差分编码(TS_2DIFF)。
 
 定频数据编码无法用于非定频数据,建议使用二阶差分编码(TS_2DIFF)进行处理。
 
diff --git a/server/src/assembly/resources/conf/iotdb-engine.properties b/server/src/assembly/resources/conf/iotdb-engine.properties
index c9f6ded..81e209e 100644
--- a/server/src/assembly/resources/conf/iotdb-engine.properties
+++ b/server/src/assembly/resources/conf/iotdb-engine.properties
@@ -543,11 +543,11 @@ max_string_length=128
 float_precision=2
 
 # Encoder configuration
-# Encoder of time series, supports TS_2DIFF, PLAIN and RLE(run-length encoding) and default value is TS_2DIFF
+# Encoder of time series, supports TS_2DIFF, PLAIN and RLE(run-length encoding), REGULAR and default value is TS_2DIFF
 time_encoder=TS_2DIFF
 
 # Encoder of value series. default value is PLAIN.
-# For int, long data type, also supports TS_2DIFF and RLE(run-length encoding), REGULAR and GORILLA.
+# For int, long data type, also supports TS_2DIFF and RLE(run-length encoding) and GORILLA.
 # For float, double data type, also supports TS_2DIFF, RLE(run-length encoding) and GORILLA.
 # For text data type, only supports PLAIN.
 value_encoder=PLAIN
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java
index 00e76e1..092031d 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java
@@ -93,6 +93,10 @@ public class IoTDBConfigCheck {
   private static final String VIRTUAL_STORAGE_GROUP_NUM = "virtual_storage_group_num";
   private static String virtualStorageGroupNum = String.valueOf(config.getVirtualStorageGroupNum());
 
+  private static final String TIME_ENCODER_KEY = "time_encoder";
+  private static String timeEncoderValue = String
+          .valueOf(TSFileDescriptor.getInstance().getConfig().getTimeEncoder());
+
   private static final String IOTDB_VERSION_STRING = "iotdb_version";
 
   public static IoTDBConfigCheck getInstance() {
@@ -144,6 +148,7 @@ public class IoTDBConfigCheck {
     systemProperties.put(TAG_ATTRIBUTE_SIZE_STRING, tagAttributeTotalSize);
     systemProperties.put(MAX_DEGREE_OF_INDEX_STRING, maxDegreeOfIndexNode);
     systemProperties.put(VIRTUAL_STORAGE_GROUP_NUM, virtualStorageGroupNum);
+    systemProperties.put(TIME_ENCODER_KEY, timeEncoderValue);
   }
 
 
@@ -316,6 +321,10 @@ public class IoTDBConfigCheck {
     if (!(properties.getProperty(VIRTUAL_STORAGE_GROUP_NUM).equals(virtualStorageGroupNum))) {
       printErrorLogAndExit(VIRTUAL_STORAGE_GROUP_NUM);
     }
+
+    if (!(properties.getProperty(TIME_ENCODER_KEY).equals(timeEncoderValue))) {
+      printErrorLogAndExit(TIME_ENCODER_KEY);
+    }
   }
 
   private void printErrorLogAndExit(String property) {
diff --git a/server/src/main/java/org/apache/iotdb/db/utils/SchemaUtils.java b/server/src/main/java/org/apache/iotdb/db/utils/SchemaUtils.java
index c93bd98..c8d22b0 100644
--- a/server/src/main/java/org/apache/iotdb/db/utils/SchemaUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/utils/SchemaUtils.java
@@ -63,7 +63,6 @@ public class SchemaUtils {
     intSet.add(TSEncoding.PLAIN);
     intSet.add(TSEncoding.RLE);
     intSet.add(TSEncoding.TS_2DIFF);
-    intSet.add(TSEncoding.REGULAR);
     intSet.add(TSEncoding.GORILLA);
     schemaChecker.put(TSDataType.INT32, intSet);
     schemaChecker.put(TSDataType.INT64, intSet);
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBCheckConfigIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBCheckConfigIT.java
new file mode 100644
index 0000000..784c988
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBCheckConfigIT.java
@@ -0,0 +1,157 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.iotdb.db.conf.IoTDBConfigCheck;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.engine.fileSystem.SystemFileFactory;
+import org.apache.iotdb.db.service.IoTDB;
+import org.apache.iotdb.db.utils.EnvironmentUtils;
+import org.apache.iotdb.tsfile.common.conf.TSFileConfig;
+import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.io.ByteArrayOutputStream;
+import java.security.AccessControlException;
+import java.security.Permission;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+
+public class IoTDBCheckConfigIT {
+  private File propertiesFile = SystemFileFactory.INSTANCE
+          .getFile(IoTDBDescriptor.getInstance().getConfig().getSchemaDir()
+          + File.separator + "system.properties");
+
+  private TSFileConfig tsFileConfig = TSFileDescriptor.getInstance().getConfig();
+
+  private Map<String, String> systemProperties = new HashMap<>();
+
+  private Properties  properties = new Properties();
+
+  private PrintStream console = null;
+  private ByteArrayOutputStream bytes = null;
+
+  @Before
+  public void setUp() throws Exception {
+    EnvironmentUtils.closeStatMonitor();
+    EnvironmentUtils.envSetUp();
+
+    final SecurityManager securityManager = new SecurityManager() {
+      public void checkPermission(Permission permission) {
+        if (permission.getName().startsWith("exitVM")) {
+          throw new AccessControlException("Wrong system config");
+        }
+      }
+    };
+    System.setSecurityManager(securityManager);
+    bytes = new ByteArrayOutputStream();
+    console = System.out;
+    System.setOut(new PrintStream(bytes));
+
+    systemProperties.put("partition_interval", "604800");
+    systemProperties.put("timestamp_precision", "ms");
+    systemProperties.put("tsfile_storage_fs", "LOCAL");
+    systemProperties.put("enable_partition", "false");
+    systemProperties.put("max_degree_of_index_node", "1024");
+    systemProperties.put("tag_attribute_total_size", "700");
+    systemProperties.put("iotdb_version", "0.11.2");
+    systemProperties.put("virtual_storage_group_num", "1");
+
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    EnvironmentUtils.cleanEnv();
+    systemProperties.clear();
+    properties.clear();
+  }
+
+  @Test
+  public void testSaveTimeEncoderToSystemProperties() throws Exception {
+    try {
+      IoTDBConfigCheck.getInstance().checkConfig();
+    } finally {
+      System.setSecurityManager(null);
+    }
+
+    // read properties from system.properties
+    try (FileInputStream inputStream = new FileInputStream(propertiesFile);
+         InputStreamReader inputStreamReader = new InputStreamReader(inputStream, TSFileConfig.STRING_CHARSET)) {
+      properties.load(inputStreamReader);
+    }
+    String timeEncoder = (String) properties.get("time_encoder");
+    assertTrue(!timeEncoder.isEmpty());
+  }
+
+  @Test
+  public void testAlterTimeEncoderAfterStartService() throws Exception {
+    EnvironmentUtils.shutdownDaemon();
+    EnvironmentUtils.stopDaemon();
+    IoTDB.metaManager.clear();
+    systemProperties.put("time_encoder", "REGULAR");
+    writeSystemFile();
+    EnvironmentUtils.reactiveDaemon();
+    try {
+      IoTDBConfigCheck.getInstance().checkConfig();
+    } catch (Throwable t) {
+      assertEquals("Wrong system config", t.getMessage());
+    } finally {
+      System.setSecurityManager(null);
+    }
+    assertTrue(bytes.toString().contains("Wrong time_encoder, please set as: REGULAR"));
+  }
+
+  @Test
+  public void testSameTimeEncoderAfterStartService() throws Exception {
+    EnvironmentUtils.shutdownDaemon();
+    EnvironmentUtils.stopDaemon();
+    IoTDB.metaManager.clear();
+    systemProperties.put("time_encoder", "TS_2DIFF");
+    writeSystemFile();
+    EnvironmentUtils.reactiveDaemon();
+    try {
+      IoTDBConfigCheck.getInstance().checkConfig();
+    } catch (Throwable t) {
+      assertTrue(false);
+    } finally {
+      System.setSecurityManager(null);
+    }
+  }
+
+  private void writeSystemFile() throws IOException {
+    // write properties to system.properties
+    try (FileOutputStream outputStream = new FileOutputStream(propertiesFile)) {
+      systemProperties.forEach((k, v) -> properties.setProperty(k, v));
+      properties.store(outputStream, "System properties:");
+    }
+  }
+}
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBEncodingIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBEncodingIT.java
new file mode 100644
index 0000000..8cffc15
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBEncodingIT.java
@@ -0,0 +1,276 @@
+/*
+ * 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;
+
+import org.apache.iotdb.db.engine.StorageEngine;
+import org.apache.iotdb.db.utils.EnvironmentUtils;
+import org.apache.iotdb.jdbc.Config;
+import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class IoTDBEncodingIT {
+
+  private static int partitionInterval = 100;
+
+  @Before
+  public void setUp() throws Exception {
+    EnvironmentUtils.closeStatMonitor();
+    EnvironmentUtils.envSetUp();
+    TSFileDescriptor.getInstance().getConfig().setTimeEncoder("REGULAR");
+    StorageEngine.setEnablePartition(true);
+    StorageEngine.setTimePartitionInterval(partitionInterval);
+    insertData();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    StorageEngine.setEnablePartition(false);
+    StorageEngine.setTimePartitionInterval(-1);
+    TSFileDescriptor.getInstance().getConfig().setTimeEncoder("TS_2DIFF");
+    EnvironmentUtils.cleanEnv();
+  }
+
+
+
+
+  @Test
+  public void testSetEncodingRegularFailed() {
+    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.test1.s0 WITH DATATYPE=INT64,ENCODING=REGULAR");
+
+    } catch (SQLException e) {
+      assertEquals(303, e.getErrorCode());
+    }
+  }
+
+  @Test
+  public void testSetTimeEncoderRegularAndValueEncoderTS_2DIFF() {
+    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=TS_2DIFF");
+      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 testSetTimeEncoderRegularAndValueEncoderTS_2DIFFOutofOrder() {
+    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=TS_2DIFF");
+      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 testSetTimeEncoderRegularAndValueEncoderRLE() {
+    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=RLE");
+      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 testSetTimeEncoderRegularAndValueEncoderRLEOutofOrder() {
+    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=RLE");
+      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 testSetTimeEncoderRegularAndValueEncoderGORILLA() {
+    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=GORILLA");
+      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 testSetTimeEncoderRegularAndValueEncoderGORILLAOutofOrder() {
+    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=GORILLA");
+      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();
+    }
+  }
+
+  private static void insertData() throws ClassNotFoundException {
+    List<String> sqls = new ArrayList<>(Arrays.asList(
+        "SET STORAGE GROUP TO root.test1",
+        "SET STORAGE GROUP TO root.test2",
+        "CREATE TIMESERIES root.test1.s0 WITH DATATYPE=INT64,ENCODING=PLAIN",
+        "CREATE TIMESERIES root.test2.s0 WITH DATATYPE=INT64,ENCODING=PLAIN"
+    ));
+    // 10 partitions, each one with one seq file and one unseq file
+    for (int i = 0; i < 10; i++) {
+      // seq files
+      for (int j = 1; j <= 2; j++) {
+        sqls.add(String.format("INSERT INTO root.test%d(timestamp, s0) VALUES (%d, %d)", j,
+            i * partitionInterval + 50, i * partitionInterval + 50));
+      }
+      // last file is unclosed
+      if (i < 9) {
+        sqls.add("FLUSH");
+      }
+      // unseq files
+      for (int j = 1; j <= 2; j++) {
+        sqls.add(String.format("INSERT INTO root.test%d(timestamp, s0) VALUES (%d, %d)", j,
+            i * partitionInterval, i * partitionInterval));
+      }
+      sqls.add("MERGE");
+      // last file is unclosed
+      if (i < 9) {
+        sqls.add("FLUSH");
+      }
+    }
+    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()) {
+
+      for (String sql : sqls) {
+        statement.execute(sql);
+      }
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+}