You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by le...@apache.org on 2023/02/03 15:50:34 UTC

[iotdb] 14/28: fix bug about learn twice

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

leirui pushed a commit to branch research/M4-visualization
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit bfe5d3aee34d0585c94e52d0f555c2cbb5463ba6
Author: Lei Rui <10...@qq.com>
AuthorDate: Fri Jan 27 20:00:58 2023 +0800

    fix bug about learn twice
---
 .../src/assembly/resources/conf/iotdb-engine.properties   |  2 +-
 .../main/java/org/apache/iotdb/db/conf/IoTDBConfig.java   |  2 +-
 .../tsfile/file/metadata/statistics/StepRegress.java      | 15 +++++++++++++--
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/server/src/assembly/resources/conf/iotdb-engine.properties b/server/src/assembly/resources/conf/iotdb-engine.properties
index 7580172460..209e4fc389 100644
--- a/server/src/assembly/resources/conf/iotdb-engine.properties
+++ b/server/src/assembly/resources/conf/iotdb-engine.properties
@@ -626,7 +626,7 @@ enable_unseq_compaction=false
 
 # Encoder configuration
 # Encoder of time series, supports TS_2DIFF, PLAIN and RLE(run-length encoding), REGULAR and default value is TS_2DIFF
-# time_encoder=TS_2DIFF
+time_encoder=PLAIN
 
 # Encoder of value series. default value is PLAIN.
 # For int, long data type, also supports TS_2DIFF and RLE(run-length encoding) and GORILLA.
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 725c38d571..e9d333f0e8 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
@@ -311,7 +311,7 @@ public class IoTDBConfig {
   private long closeTsFileCheckInterval = 10 * 60 * 1000L;
 
   /** When average series point number reaches this, flush the memtable to disk */
-  private int avgSeriesPointNumberThreshold = 10000;
+  private int avgSeriesPointNumberThreshold = 100;
 
   /**
    * Work when tsfile_manage_strategy is level_strategy. When merge point number reaches this, merge
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/StepRegress.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/StepRegress.java
index d75375d960..918f2ddf2e 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/StepRegress.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/StepRegress.java
@@ -27,6 +27,10 @@ import java.util.Arrays;
 
 public class StepRegress {
 
+  // this is necessary, otherwise serialized twice by timeseriesMetadata and chunkMetadata
+  // causing learn() executed more than once!!
+  private boolean isLearned = false;
+
   private double slope = 0;
 
   // when learning parameters, we first determine segmentIntercepts and then determine segmentKeys;
@@ -91,10 +95,17 @@ public class StepRegress {
   }
 
   /**
-   * learn the parameters of the step regression function for the loaded data. Executed once and
-   * only once when serializing.
+   * learn the parameters (slope and segmentKeys) of the step regression function for the loaded
+   * data. Executed once and only once when serializing.
    */
   public void learn() throws IOException {
+    if (isLearned) {
+      // this is necessary, otherwise serialized twice by timeseriesMetadata and chunkMetadata
+      // causing learn() executed more than once!!
+      return;
+    }
+    isLearned = true;
+
     if (intervals.size() == 0) { // only one point
       this.segmentKeys.add(timestamps.get(0)); // t1
       return;