Caideyipi commented on code in PR #18589:
URL: https://github.com/apache/iotdb/pull/18589#discussion_r4478268967
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/udf/builtin/UDTFEqualSizeBucketOutlierSample.java:
##########
@@ -354,14 +368,12 @@ public void outlierSampleLong(RowWindow rowWindow,
PointCollector collector)
currentValue = rowWindow.getRow(i).getLong(0);
nextValue = rowWindow.getRow(i + 1).getLong(0);
- x1 = currentTime - lastTime;
- x2 = nextTime - currentTime;
- y1 = currentValue - lastValue;
- y2 = nextValue - currentValue;
+ x1 = timeDifferenceAsDouble(currentTime, lastTime);
+ x2 = timeDifferenceAsDouble(nextTime, currentTime);
+ y1 = timeDifferenceAsDouble(currentValue, lastValue);
+ y2 = timeDifferenceAsDouble(nextValue, currentValue);
Review Comment:
Added three INT64 regression tests for cos, prenextdis, and stendis in
4c0daa4a997. Each uses B + [0, 1, 10, 1, 0] with B = 1L << 60 and verifies that
the collector emits exactly the central spike at timestamp 2.
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/FixedIntervalFillFilter.java:
##########
@@ -34,14 +36,6 @@ public FixedIntervalFillFilter(long timeInterval) {
public boolean needFill(long time, long previousTime) {
// the reason that we use Math.abs is that we may use order by time desc
which will cause
// previousTime is larger than time
- return isTimeDistanceLessThanOrEqual(time, previousTime, timeInterval);
- }
-
- private boolean isTimeDistanceLessThanOrEqual(long left, long right, long
maxDistance) {
- if (maxDistance < 0) {
- return false;
- }
- long distance = left >= right ? left - right : right - left;
- return Long.compareUnsigned(distance, maxDistance) <= 0;
+ return isTimeDistanceLessThanOrEqualTo(time, previousTime, timeInterval);
Review Comment:
Added the 180-day nanosecond threshold regression in 4c0daa4a997. It accepts
the exact interval and rejects interval + 1 in both time orders, and also
covers the Long.MIN_VALUE/Long.MAX_VALUE distance with a Long.MAX_VALUE
interval.
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/FixedIntervalFillFilter.java:
##########
@@ -21,6 +21,8 @@
import
org.apache.iotdb.db.queryengine.execution.operator.process.fill.IFillFilter;
+import static
org.apache.iotdb.db.pipe.processor.downsampling.DownSamplingTimeUtils.isTimeDistanceLessThanOrEqualTo;
Review Comment:
Updated in 4c0daa4a997 to mirror master: FixedIntervalFillFilter now keeps
the unsigned-distance comparison in a private static
isTimeDistanceLessThanOrEqual method, removing its dependency on the pipe
downsampling package.
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/DateTimeUtils.java:
##########
@@ -591,32 +592,43 @@ public static long convertDurationStrToLong(
*/
public static long convertDurationStrToLong(
long currentTime, String duration, String timestampPrecision, boolean
convertYearToMonth) {
- long total = 0;
- long temp = 0;
- for (int i = 0; i < duration.length(); i++) {
- char ch = duration.charAt(i);
- if (Character.isDigit(ch)) {
- temp *= 10;
- temp += (ch - '0');
- } else {
- String unit = String.valueOf(duration.charAt(i));
- // This is to identify units with two letters.
- if (i + 1 < duration.length() && !Character.isDigit(duration.charAt(i
+ 1))) {
- i++;
- unit += duration.charAt(i);
- }
- unit = unit.toLowerCase();
- if (convertYearToMonth && unit.equals("y")) {
- temp *= 12;
- unit = "mo";
+ try {
+ long total = 0;
+ long temp = 0;
+ for (int i = 0; i < duration.length(); i++) {
+ char ch = duration.charAt(i);
+ if (Character.isDigit(ch)) {
+ temp = Math.addExact(Math.multiplyExact(temp, 10),
Character.digit(ch, 10));
+ } else {
+ String unit = String.valueOf(duration.charAt(i));
+ // This is to identify units with two letters.
+ if (i + 1 < duration.length() &&
!Character.isDigit(duration.charAt(i + 1))) {
+ i++;
+ unit += duration.charAt(i);
+ }
+ unit = unit.toLowerCase();
+ if (convertYearToMonth && unit.equals("y")) {
+ temp = Math.multiplyExact(temp, 12);
+ unit = "mo";
+ }
+ long componentCurrentTime =
+ isMonthUnit(unit) ? (currentTime == -1 ? -1 :
Math.addExact(currentTime, total)) : -1;
Review Comment:
Added both regressions in 4c0daa4a997: direct parsing of 1s1ns near
Long.MAX_VALUE and StatementGenerator parsing at ns precision with UTC. The SQL
test checks the exact timestamp predicate, equivalence with - 1000000001ns, and
rejection of + 1s1ns. It restores the original timestamp precision in a finally
block.
--
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]