Caideyipi commented on code in PR #18589:
URL: https://github.com/apache/iotdb/pull/18589#discussion_r3964059561


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/ai/InferenceOperator.java:
##########
@@ -374,4 +378,27 @@ public long ramBytesUsed() {
             ? 0
             : 
targetColumnNames.stream().mapToLong(RamUsageEstimator::sizeOf).sum());
   }
+
+  static long calculateGeneratedTimeInterval(long minTimestamp, long 
maxTimestamp, long totalRow) {
+    try {
+      BigInteger interval =
+          BigInteger.valueOf(maxTimestamp)
+              .subtract(BigInteger.valueOf(minTimestamp))
+              .divide(BigInteger.valueOf(totalRow));
+      if (interval.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0) {
+        throw new ArithmeticException();
+      }
+      return interval.longValue();
+    } catch (ArithmeticException e) {
+      throw new 
ModelInferenceProcessException(GENERATED_TIME_COLUMN_OUT_OF_RANGE_MESSAGE);
+    }
+  }
+
+  static long calculateGeneratedTime(long maxTimestamp, long interval, long 
currentRowIndex) {
+    try {
+      return Math.addExact(maxTimestamp, Math.multiplyExact(interval, 
currentRowIndex));

Review Comment:
   Fixed in 7b3c9a2208f. Generated timestamps are now evaluated as maxTimestamp 
+ interval * rowIndex in BigInteger, with the completed value range-checked 
before conversion. This allows a mathematically valid final timestamp even when 
the intermediate product alone exceeds long range, while still rejecting an 
out-of-range final result.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to