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 8eaadfc497 Enable time partition by default (#7800)
8eaadfc497 is described below

commit 8eaadfc49705dba2ee2aae6fe61041bdd4d274f4
Author: Haonan <[email protected]>
AuthorDate: Sun Oct 30 23:29:03 2022 +0800

    Enable time partition by default (#7800)
---
 .../resources/conf/iotdb-common.properties         |  2 +-
 .../java/org/apache/iotdb/db/conf/IoTDBConfig.java |  2 +-
 .../iotdb/db/utils/TsFileRewriteToolTest.java      | 47 ++++++++++++----------
 3 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/node-commons/src/assembly/resources/conf/iotdb-common.properties 
b/node-commons/src/assembly/resources/conf/iotdb-common.properties
index 139f801a86..f1c5f53f91 100644
--- a/node-commons/src/assembly/resources/conf/iotdb-common.properties
+++ b/node-commons/src/assembly/resources/conf/iotdb-common.properties
@@ -930,7 +930,7 @@ timestamp_precision=ms
 
 # whether enable data partition. If disabled, all data belongs to partition 0
 # Datatype: boolean
-# enable_partition=false
+# enable_partition=true
 
 # time range for partitioning data inside each data region, the unit is 
millisecond, default is equal to one week
 # Datatype: long
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java 
b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
index 88bd163935..d9e0a690eb 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
@@ -746,7 +746,7 @@ public class IoTDBConfig {
   private int primitiveArraySize = 32;
 
   /** whether enable data partition. If disabled, all data belongs to 
partition 0 */
-  private boolean enablePartition = false;
+  private boolean enablePartition = true;
 
   /** Time partition interval for storage in milliseconds */
   private long timePartitionIntervalForStorage = 604_800_000;
diff --git 
a/server/src/test/java/org/apache/iotdb/db/utils/TsFileRewriteToolTest.java 
b/server/src/test/java/org/apache/iotdb/db/utils/TsFileRewriteToolTest.java
index 1b20132147..7422203323 100644
--- a/server/src/test/java/org/apache/iotdb/db/utils/TsFileRewriteToolTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/utils/TsFileRewriteToolTest.java
@@ -54,6 +54,7 @@ import org.apache.commons.io.FileUtils;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 
 import java.io.File;
@@ -65,7 +66,6 @@ import java.util.Map;
 
 public class TsFileRewriteToolTest {
 
-  private final boolean newEnablePartition = true;
   private final long newPartitionInterval = 3600_000;
   protected final long maxTimestamp = 100000000L;
   protected final String folder = "target" + File.separator + "split";
@@ -92,6 +92,7 @@ public class TsFileRewriteToolTest {
     originEnablePartition = config.isEnablePartition();
     originPartitionInterval = config.getTimePartitionIntervalForStorage();
 
+    boolean newEnablePartition = true;
     config.setEnablePartition(newEnablePartition);
     config.setTimePartitionIntervalForStorage(newPartitionInterval);
 
@@ -166,6 +167,7 @@ public class TsFileRewriteToolTest {
     splitFileAndQueryCheck(deviceSensorsMap);
   }
 
+  @Ignore
   @Test
   public void loadFileTest() {
     HashMap<String, List<String>> deviceSensorsMap = new HashMap<>();
@@ -296,33 +298,34 @@ public class TsFileRewriteToolTest {
   protected void createOneTsFile(HashMap<String, List<String>> 
deviceSensorsMap) {
     try {
       File f = FSFactoryProducer.getFSFactory().getFile(path);
-      TsFileWriter tsFileWriter = new TsFileWriter(f);
-      // add measurements into file schema
-      try {
-        for (Map.Entry<String, List<String>> entry : 
deviceSensorsMap.entrySet()) {
-          String device = entry.getKey();
-          for (String sensor : entry.getValue()) {
-            tsFileWriter.registerTimeseries(
-                new Path(device), new MeasurementSchema(sensor, 
TSDataType.INT64, TSEncoding.RLE));
+      try (TsFileWriter tsFileWriter = new TsFileWriter(f)) {
+        // add measurements into file schema
+        try {
+          for (Map.Entry<String, List<String>> entry : 
deviceSensorsMap.entrySet()) {
+            String device = entry.getKey();
+            for (String sensor : entry.getValue()) {
+              tsFileWriter.registerTimeseries(
+                  new Path(device),
+                  new MeasurementSchema(sensor, TSDataType.INT64, 
TSEncoding.RLE));
+            }
           }
+        } catch (WriteProcessException e) {
+          Assert.fail(e.getMessage());
         }
-      } catch (WriteProcessException e) {
-        Assert.fail(e.getMessage());
-      }
 
-      for (long timestamp = 0; timestamp < maxTimestamp; timestamp += 1000) {
-        for (Map.Entry<String, List<String>> entry : 
deviceSensorsMap.entrySet()) {
-          String device = entry.getKey();
-          TSRecord tsRecord = new TSRecord(timestamp, device);
-          for (String sensor : entry.getValue()) {
-            DataPoint dataPoint = new LongDataPoint(sensor, timestamp + 
VALUE_OFFSET);
-            tsRecord.addTuple(dataPoint);
+        for (long timestamp = 0; timestamp < maxTimestamp; timestamp += 1000) {
+          for (Map.Entry<String, List<String>> entry : 
deviceSensorsMap.entrySet()) {
+            String device = entry.getKey();
+            TSRecord tsRecord = new TSRecord(timestamp, device);
+            for (String sensor : entry.getValue()) {
+              DataPoint dataPoint = new LongDataPoint(sensor, timestamp + 
VALUE_OFFSET);
+              tsRecord.addTuple(dataPoint);
+            }
+            tsFileWriter.write(tsRecord);
           }
-          tsFileWriter.write(tsRecord);
         }
+        tsFileWriter.flushAllChunkGroups();
       }
-      tsFileWriter.flushAllChunkGroups();
-      tsFileWriter.close();
     } catch (Throwable e) {
       Assert.fail(e.getMessage());
     }

Reply via email to