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 d7c95f4547e2c4f2338b994787029903913edacb
Author: Lei Rui <[email protected]>
AuthorDate: Thu Jan 26 17:11:18 2023 +0800

    fix
---
 .../org/apache/iotdb/db/integration/m4/MyTest1.java   |  2 ++
 .../org/apache/iotdb/db/integration/m4/MyTest2.java   |  4 +++-
 .../org/apache/iotdb/db/integration/m4/MyTest3.java   |  4 +++-
 .../org/apache/iotdb/db/integration/m4/MyTest4.java   |  4 +++-
 .../tsfile/file/metadata/statistics/Statistics.java   | 19 +++++++++++++------
 .../tsfile/file/metadata/statistics/StepRegress.java  | 11 ++++++++++-
 .../iotdb/tsfile/read/common/ChunkSuit4CPV.java       |  2 +-
 7 files changed, 35 insertions(+), 11 deletions(-)

diff --git 
a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest1.java 
b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest1.java
index 29ad2828b1..f03641955f 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest1.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest1.java
@@ -24,6 +24,7 @@ import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.engine.compaction.CompactionStrategy;
 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.Assert;
@@ -60,6 +61,7 @@ public class MyTest1 {
 
   @Before
   public void setUp() throws Exception {
+    TSFileDescriptor.getInstance().getConfig().setTimeEncoder("PLAIN");
     originalCompactionStrategy = config.getCompactionStrategy();
     config.setCompactionStrategy(CompactionStrategy.NO_COMPACTION);
 
diff --git 
a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest2.java 
b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest2.java
index cc9ef2ba6a..eb3ca32127 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest2.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest2.java
@@ -23,6 +23,7 @@ import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.engine.compaction.CompactionStrategy;
 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.Assert;
@@ -44,7 +45,7 @@ public class MyTest2 {
   private static String[] creationSqls =
       new String[] {
         "SET STORAGE GROUP TO root.vehicle.d0",
-        "CREATE TIMESERIES root.vehicle.d0.s0 WITH DATATYPE=INT32, 
ENCODING=RLE",
+        "CREATE TIMESERIES root.vehicle.d0.s0 WITH DATATYPE=INT64, 
ENCODING=PLAIN",
       };
 
   private final String d0s0 = "root.vehicle.d0.s0";
@@ -61,6 +62,7 @@ public class MyTest2 {
 
   @Before
   public void setUp() throws Exception {
+    TSFileDescriptor.getInstance().getConfig().setTimeEncoder("PLAIN");
     EnvironmentUtils.envSetUp();
     Class.forName(Config.JDBC_DRIVER_NAME);
 
diff --git 
a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest3.java 
b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest3.java
index 5bcce47a66..eb7b06b28d 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest3.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest3.java
@@ -24,6 +24,7 @@ import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.engine.compaction.CompactionStrategy;
 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.Assert;
@@ -45,7 +46,7 @@ public class MyTest3 {
   private static String[] creationSqls =
       new String[] {
         "SET STORAGE GROUP TO root.vehicle.d0",
-        "CREATE TIMESERIES root.vehicle.d0.s0 WITH DATATYPE=DOUBLE",
+        "CREATE TIMESERIES root.vehicle.d0.s0 WITH 
DATATYPE=DOUBLE,ENCODING=PLAIN",
       };
 
   private final String d0s0 = "root.vehicle.d0.s0";
@@ -59,6 +60,7 @@ public class MyTest3 {
 
   @Before
   public void setUp() throws Exception {
+    TSFileDescriptor.getInstance().getConfig().setTimeEncoder("PLAIN");
     originalCompactionStrategy = config.getCompactionStrategy();
     config.setCompactionStrategy(CompactionStrategy.NO_COMPACTION);
 
diff --git 
a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest4.java 
b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest4.java
index bafb22478b..70930a9b13 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest4.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest4.java
@@ -24,6 +24,7 @@ import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.engine.compaction.CompactionStrategy;
 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.Assert;
@@ -45,7 +46,7 @@ public class MyTest4 {
   private static String[] creationSqls =
       new String[] {
         "SET STORAGE GROUP TO root.vehicle.d0",
-        "CREATE TIMESERIES root.vehicle.d0.s0 WITH DATATYPE=INT32, 
ENCODING=RLE",
+        "CREATE TIMESERIES root.vehicle.d0.s0 WITH DATATYPE=INT64, 
ENCODING=PLAIN",
       };
 
   private final String d0s0 = "root.vehicle.d0.s0";
@@ -59,6 +60,7 @@ public class MyTest4 {
 
   @Before
   public void setUp() throws Exception {
+    TSFileDescriptor.getInstance().getConfig().setTimeEncoder("PLAIN");
     originalCompactionStrategy = config.getCompactionStrategy();
     config.setCompactionStrategy(CompactionStrategy.NO_COMPACTION);
 
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/Statistics.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/Statistics.java
index e70f3afdab..1d22cd29d3 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/Statistics.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/Statistics.java
@@ -129,6 +129,10 @@ public abstract class Statistics<T> {
     return byteLen;
   }
 
+  /**
+   * slope, m: the number of segment keys, m-2 segment keys in between when 
m>=2. The first and the
+   * last segment keys are not serialized here, because they are minTime and 
endTime respectively.
+   */
   int serializeStepRegress(OutputStream outputStream) throws IOException {
     int byteLen = 0;
     stepRegress.learn(); // TODO ensure excuted once and only once
@@ -500,14 +504,17 @@ public abstract class Statistics<T> {
     int m = ReadWriteIOUtils.readInt(byteBuffer); // m
     DoubleArrayList segmentKeys = new DoubleArrayList();
     segmentKeys.add(this.startTime); // t1
-    for (int i = 0; i < m - 2; i++) { // t2,t3,...,tm-1
-      segmentKeys.add(ReadWriteIOUtils.readDouble(byteBuffer));
+    if (m > 1) { // TODO DEBUG
+      for (int i = 0; i < m - 2; i++) { // t2,t3,...,tm-1
+        segmentKeys.add(ReadWriteIOUtils.readDouble(byteBuffer));
+      }
+      segmentKeys.add(this.endTime);
     }
-    segmentKeys.add(this.endTime);
     this.stepRegress.setSegmentKeys(segmentKeys);
-    this.stepRegress
-        .inferInterceptsFromSegmentKeys(); // don't forget this, execute once 
and only once when
-    // deserializing
+    if (m > 1) {
+      // don't forget this, execute once and only once when
+      this.stepRegress.inferInterceptsFromSegmentKeys();
+    }
   }
 
   public long getStartTime() {
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 c7dc0cb50b..cb4c3450e7 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,7 +27,7 @@ import java.util.Arrays;
 
 public class StepRegress {
 
-  private double slope;
+  private double slope = 0;
 
   // when learning parameters, we first determine segmentIntercepts and then 
determine segmentKeys;
   // when using functions, we read segmentKeys and then infer 
segmentIntercepts.
@@ -95,6 +95,11 @@ public class StepRegress {
    * only once when serializing.
    */
   public void learn() throws IOException {
+    if (intervals.size() == 0) { // only one point
+      this.segmentKeys.add(timestamps.get(0)); // t1
+      return;
+    }
+
     initForLearn();
 
     int tiltLatestSegmentID = 0;
@@ -380,6 +385,10 @@ public class StepRegress {
    *     in the chunk. Pay attention that f(t) starts from (startTime,1), ends 
at (endTime,count).
    */
   public double infer(double t) throws IOException {
+    if (segmentKeys.size() == 1) { // TODO DEBUG
+      return 1;
+    }
+
     if (t < segmentKeys.get(0) || t > segmentKeys.getLast()) {
       throw new IOException(
           String.format(
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/ChunkSuit4CPV.java 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/ChunkSuit4CPV.java
index 8143013834..240435a615 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/ChunkSuit4CPV.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/ChunkSuit4CPV.java
@@ -383,7 +383,7 @@ public class ChunkSuit4CPV {
     // since we have constrained that targetTimestamp must be within the chunk 
time range
     // [startTime, endTime],
     // estimatedPos will not be out of range.
-    return pageReader.timeBuffer.get(estimatedPos) == targetTimestamp;
+    return pageReader.timeBuffer.getLong(estimatedPos * 8) == targetTimestamp;
   }
 
   public void updateFP(MinMaxInfo point) {

Reply via email to