This is an automated email from the ASF dual-hosted git repository.
jackietien 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 8b5a6d7bfa7 [IOTDB-6298] Fix number overflow in group by time interval
8b5a6d7bfa7 is described below
commit 8b5a6d7bfa7372579c40841107132d077e7cfddb
Author: Jackie Tien <[email protected]>
AuthorDate: Thu Feb 22 16:20:46 2024 +0800
[IOTDB-6298] Fix number overflow in group by time interval
---
.../src/main/java/org/apache/iotdb/db/utils/DateTimeUtils.java | 6 +++---
.../src/test/java/org/apache/iotdb/db/utils/DateTimeUtilsTest.java | 3 +++
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/DateTimeUtils.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/DateTimeUtils.java
index 6953c81d630..5e04f97504b 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/DateTimeUtils.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/DateTimeUtils.java
@@ -779,8 +779,8 @@ public class DateTimeUtils {
public static TimeDuration constructTimeDuration(String duration) {
duration = duration.toLowerCase();
String currTimePrecision =
CommonDescriptor.getInstance().getConfig().getTimestampPrecision();
- int temp = 0;
- int monthDuration = 0;
+ long temp = 0;
+ long monthDuration = 0;
long nonMonthDuration = 0;
for (int i = 0; i < duration.length(); i++) {
char ch = duration.charAt(i);
@@ -809,6 +809,6 @@ public class DateTimeUtils {
temp = 0;
}
}
- return new TimeDuration(monthDuration, nonMonthDuration);
+ return new TimeDuration((int) monthDuration, nonMonthDuration);
}
}
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/DateTimeUtilsTest.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/DateTimeUtilsTest.java
index a4258723271..a7ed50c287a 100644
---
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/DateTimeUtilsTest.java
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/DateTimeUtilsTest.java
@@ -261,5 +261,8 @@ public class DateTimeUtilsTest {
timeDuration = DateTimeUtils.constructTimeDuration("1y1mo");
Assert.assertEquals(13, timeDuration.monthDuration);
Assert.assertEquals(0, timeDuration.nonMonthDuration);
+
+ timeDuration = DateTimeUtils.constructTimeDuration("10000000000ms");
+ Assert.assertEquals(10000000000L, timeDuration.nonMonthDuration);
}
}