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

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

commit c8271c9b9d1aebbbe282143a2557eeb6dc915d7e
Author: Lei Rui <[email protected]>
AuthorDate: Fri Oct 4 22:35:58 2024 +0800

    add
---
 .../apache/iotdb/db/query/udf/builtin/UDTFM4MAC.java    | 17 +++++++++--------
 .../apache/iotdb/db/query/udf/builtin/UDTFMinMax.java   | 17 +++++++++--------
 2 files changed, 18 insertions(+), 16 deletions(-)

diff --git 
a/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/UDTFM4MAC.java 
b/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/UDTFM4MAC.java
index 9629a23dc51..02c38940010 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/UDTFM4MAC.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/UDTFM4MAC.java
@@ -119,9 +119,9 @@ public class UDTFM4MAC implements UDTF {
     tqs = parameters.getLong("tqs"); // closed
     tqe = parameters.getLong("tqe"); // open
     w = parameters.getInt("w");
-    if ((tqe - tqs) % w != 0) {
-      throw new MetadataException("You should make tqe-tqs integer divide w");
-    }
+    //    if ((tqe - tqs) % w != 0) {
+    //      throw new MetadataException("You should make tqe-tqs integer 
divide w");
+    //    }
     configurations
         .setAccessStrategy(new RowByRowAccessStrategy())
         .setOutputDataType(TSDataType.TEXT);
@@ -159,7 +159,7 @@ public class UDTFM4MAC implements UDTF {
   }
 
   protected void transformInt(long time, int value) throws IOException {
-    long intervalLen = (tqe - tqs) / w;
+    double intervalLen = (tqe - tqs) * 1.0 / w;
     int pos = (int) Math.floor((time - tqs) * 1.0 / intervalLen);
     if (pos >= w) {
       throw new IOException("Make sure the range time filter is time>=tqs and 
time<tqe");
@@ -210,7 +210,7 @@ public class UDTFM4MAC implements UDTF {
   }
 
   protected void transformLong(long time, long value) throws IOException {
-    long intervalLen = (tqe - tqs) / w;
+    double intervalLen = (tqe - tqs) * 1.0 / w;
     int pos = (int) Math.floor((time - tqs) * 1.0 / intervalLen);
 
     if (pos >= w) {
@@ -261,7 +261,7 @@ public class UDTFM4MAC implements UDTF {
   }
 
   protected void transformFloat(long time, float value) throws IOException {
-    long intervalLen = (tqe - tqs) / w;
+    double intervalLen = (tqe - tqs) * 1.0 / w;
     int pos = (int) Math.floor((time - tqs) * 1.0 / intervalLen);
 
     if (pos >= w) {
@@ -312,7 +312,7 @@ public class UDTFM4MAC implements UDTF {
   }
 
   protected void transformDouble(long time, double value) throws IOException {
-    long intervalLen = (tqe - tqs) / w;
+    double intervalLen = (tqe - tqs) * 1.0 / w;
     int pos = (int) Math.floor((time - tqs) * 1.0 / intervalLen);
 
     if (pos >= w) {
@@ -465,7 +465,8 @@ public class UDTFM4MAC implements UDTF {
     }
     // collect result
     for (int i = 0; i < w; i++) {
-      long startInterval = tqs + (tqe - tqs) / w * i;
+      //      long startInterval = tqs + (tqe - tqs) / w * i;
+      long startInterval = i;
       collector.putString(startInterval, result[i]);
     }
   }
diff --git 
a/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/UDTFMinMax.java 
b/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/UDTFMinMax.java
index b2fa3663e17..be5b1b3ca94 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/UDTFMinMax.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/UDTFMinMax.java
@@ -91,9 +91,9 @@ public class UDTFMinMax implements UDTF {
     tqs = parameters.getLong("tqs"); // closed
     tqe = parameters.getLong("tqe"); // open
     w = parameters.getInt("w");
-    if ((tqe - tqs) % w != 0) {
-      throw new MetadataException("You should make tqe-tqs integer divide w");
-    }
+    //    if ((tqe - tqs) % w != 0) {
+    //      throw new MetadataException("You should make tqe-tqs integer 
divide w");
+    //    }
     configurations
         .setAccessStrategy(new RowByRowAccessStrategy())
         .setOutputDataType(TSDataType.TEXT);
@@ -130,7 +130,7 @@ public class UDTFMinMax implements UDTF {
   }
 
   protected void transformInt(long time, int value) throws IOException {
-    long intervalLen = (tqe - tqs) / w;
+    double intervalLen = (tqe - tqs) * 1.0 / w;
     int pos = (int) Math.floor((time - tqs) * 1.0 / intervalLen);
     if (pos >= w) {
       throw new IOException("Make sure the range time filter is time>=tqs and 
time<tqe");
@@ -163,7 +163,7 @@ public class UDTFMinMax implements UDTF {
   }
 
   protected void transformLong(long time, long value) throws IOException {
-    long intervalLen = (tqe - tqs) / w;
+    double intervalLen = (tqe - tqs) * 1.0 / w;
     int pos = (int) Math.floor((time - tqs) * 1.0 / intervalLen);
 
     if (pos >= w) {
@@ -197,7 +197,7 @@ public class UDTFMinMax implements UDTF {
   }
 
   protected void transformFloat(long time, float value) throws IOException {
-    long intervalLen = (tqe - tqs) / w;
+    double intervalLen = (tqe - tqs) * 1.0 / w;
     int pos = (int) Math.floor((time - tqs) * 1.0 / intervalLen);
 
     if (pos >= w) {
@@ -231,7 +231,7 @@ public class UDTFMinMax implements UDTF {
   }
 
   protected void transformDouble(long time, double value) throws IOException {
-    long intervalLen = (tqe - tqs) / w;
+    double intervalLen = (tqe - tqs) * 1.0 / w;
     int pos = (int) Math.floor((time - tqs) * 1.0 / intervalLen);
 
     if (pos >= w) {
@@ -327,7 +327,8 @@ public class UDTFMinMax implements UDTF {
     }
     // collect result
     for (int i = 0; i < w; i++) {
-      long startInterval = tqs + (tqe - tqs) / w * i;
+      //      long startInterval = tqs + (tqe - tqs) / w * i;
+      long startInterval = i;
       collector.putString(startInterval, result[i]);
     }
   }

Reply via email to