jt2594838 commented on code in PR #18606:
URL: https://github.com/apache/iotdb/pull/18606#discussion_r4023238592
##########
iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/rate/NaiveIncreaseAccumulator.java:
##########
@@ -58,30 +60,27 @@ public TableAccumulator copy() {
@Override
public void addInput(Column[] arguments, AggregationMask mask) {
RateFunctionValidation.validateArgumentCount(arguments,
RateFunctionType.INCREASE);
- int selectedCount = mask.getSelectedPositionCount();
- int[] selectedPositions = mask.isSelectAll() ? null :
mask.getSelectedPositions();
- for (int index = 0; index < selectedCount; index++) {
- int position = mask.isSelectAll() ? index : selectedPositions[index];
- if (arguments[0].isNull(position)) {
- continue;
- }
- double value =
- RateFunctionValidation.readValue(
- arguments[0], position, valueDataType,
RateFunctionType.INCREASE);
- long time =
- RateFunctionValidation.readRequiredTime(
- arguments[1], position, RateFunctionType.INCREASE, 2);
- long currentWindowStart =
- RateFunctionValidation.readRequiredTime(
- arguments[2], position, RateFunctionType.INCREASE, 3);
- long currentWindowEnd =
- RateFunctionValidation.readRequiredTime(
- arguments[3], position, RateFunctionType.INCREASE, 4);
- RateFunctionValidation.validateWindow(
- RateFunctionType.INCREASE, time, currentWindowStart,
currentWindowEnd);
- initializeOrValidateWindow(currentWindowStart, currentWindowEnd);
- samples.add(time, value);
- }
+ TypeServices.RATE_INPUT_SERVICE
Review Comment:
NaiveIncreaseAccumulator now dispatches to a native batch reader through
RATE_INPUT_SERVICE. It preserves value validation before time/window validation
and keeps the existing state update callback, including logical group positions
where applicable. RateBatchInputTest exercises all 16 implementations with
native and wrapped columns, masks/nulls and validation cases. This is one of
the 12 retained rate candidates; the other four were restored after
fixed-DOUBLE benchmarks showed regressions.
##########
iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/rate/NaiveIrateAccumulator.java:
##########
@@ -58,21 +60,18 @@ public TableAccumulator copy() {
@Override
public void addInput(Column[] arguments, AggregationMask mask) {
RateFunctionValidation.validateArgumentCount(arguments,
RateFunctionType.IRATE);
- int selectedCount = mask.getSelectedPositionCount();
- int[] selectedPositions = mask.isSelectAll() ? null :
mask.getSelectedPositions();
- for (int index = 0; index < selectedCount; index++) {
- int position = mask.isSelectAll() ? index : selectedPositions[index];
- if (arguments[0].isNull(position)) {
- continue;
- }
- double value =
- RateFunctionValidation.readValue(
- arguments[0], position, valueDataType, RateFunctionType.IRATE);
- long time =
- RateFunctionValidation.readRequiredTime(
- arguments[1], position, RateFunctionType.IRATE, 2);
- samples.add(time, value);
- }
+ TypeServices.RATE_INPUT_SERVICE
Review Comment:
NaiveIrateAccumulator now dispatches to a native batch reader through
RATE_INPUT_SERVICE. It preserves value validation before time/window validation
and keeps the existing state update callback, including logical group positions
where applicable. RateBatchInputTest exercises all 16 implementations with
native and wrapped columns, masks/nulls and validation cases. This is one of
the 12 retained rate candidates; the other four were restored after
fixed-DOUBLE benchmarks showed regressions.
##########
iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/rate/NaiveRateAccumulator.java:
##########
@@ -58,27 +60,27 @@ public TableAccumulator copy() {
@Override
public void addInput(Column[] arguments, AggregationMask mask) {
RateFunctionValidation.validateArgumentCount(arguments,
RateFunctionType.RATE);
- int selectedCount = mask.getSelectedPositionCount();
- int[] selectedPositions = mask.isSelectAll() ? null :
mask.getSelectedPositions();
- for (int index = 0; index < selectedCount; index++) {
- int position = mask.isSelectAll() ? index : selectedPositions[index];
- if (arguments[0].isNull(position)) {
- continue;
- }
- double value =
- RateFunctionValidation.readValue(
- arguments[0], position, valueDataType, RateFunctionType.RATE);
- long time =
- RateFunctionValidation.readRequiredTime(arguments[1], position,
RateFunctionType.RATE, 2);
- long currentWindowStart =
- RateFunctionValidation.readRequiredTime(arguments[2], position,
RateFunctionType.RATE, 3);
- long currentWindowEnd =
- RateFunctionValidation.readRequiredTime(arguments[3], position,
RateFunctionType.RATE, 4);
- RateFunctionValidation.validateWindow(
- RateFunctionType.RATE, time, currentWindowStart, currentWindowEnd);
- initializeOrValidateWindow(currentWindowStart, currentWindowEnd);
- samples.add(time, value);
- }
+ TypeServices.RATE_INPUT_SERVICE
Review Comment:
NaiveRateAccumulator now dispatches to a native batch reader through
RATE_INPUT_SERVICE. It preserves value validation before time/window validation
and keeps the existing state update callback, including logical group positions
where applicable. RateBatchInputTest exercises all 16 implementations with
native and wrapped columns, masks/nulls and validation cases. This is one of
the 12 retained rate candidates; the other four were restored after
fixed-DOUBLE benchmarks showed regressions.
##########
iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/rate/OrderedDeltaAccumulator.java:
##########
@@ -56,30 +58,27 @@ public TableAccumulator copy() {
@Override
public void addInput(Column[] arguments, AggregationMask mask) {
RateFunctionValidation.validateArgumentCount(arguments,
RateFunctionType.DELTA);
- int selectedCount = mask.getSelectedPositionCount();
- int[] selectedPositions = mask.isSelectAll() ? null :
mask.getSelectedPositions();
- for (int index = 0; index < selectedCount; index++) {
- int position = mask.isSelectAll() ? index : selectedPositions[index];
- if (arguments[0].isNull(position)) {
- continue;
- }
- double value =
- RateFunctionValidation.readValue(
- arguments[0], position, valueDataType, RateFunctionType.DELTA);
- long time =
- RateFunctionValidation.readRequiredTime(
- arguments[1], position, RateFunctionType.DELTA, 2);
- long currentWindowStart =
- RateFunctionValidation.readRequiredTime(
- arguments[2], position, RateFunctionType.DELTA, 3);
- long currentWindowEnd =
- RateFunctionValidation.readRequiredTime(
- arguments[3], position, RateFunctionType.DELTA, 4);
- RateFunctionValidation.validateWindow(
- RateFunctionType.DELTA, time, currentWindowStart, currentWindowEnd);
- initializeOrValidateWindow(currentWindowStart, currentWindowEnd);
- update(time, value);
- }
+ TypeServices.RATE_INPUT_SERVICE
Review Comment:
OrderedDeltaAccumulator now dispatches to a native batch reader through
RATE_INPUT_SERVICE. It preserves value validation before time/window validation
and keeps the existing state update callback, including logical group positions
where applicable. RateBatchInputTest exercises all 16 implementations with
native and wrapped columns, masks/nulls and validation cases. This is one of
the 12 retained rate candidates; the other four were restored after
fixed-DOUBLE benchmarks showed regressions.
##########
iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/rate/OrderedIncreaseAccumulator.java:
##########
@@ -57,30 +59,27 @@ public TableAccumulator copy() {
@Override
public void addInput(Column[] arguments, AggregationMask mask) {
RateFunctionValidation.validateArgumentCount(arguments,
RateFunctionType.INCREASE);
- int selectedCount = mask.getSelectedPositionCount();
- int[] selectedPositions = mask.isSelectAll() ? null :
mask.getSelectedPositions();
- for (int index = 0; index < selectedCount; index++) {
- int position = mask.isSelectAll() ? index : selectedPositions[index];
- if (arguments[0].isNull(position)) {
- continue;
- }
- double value =
- RateFunctionValidation.readValue(
- arguments[0], position, valueDataType,
RateFunctionType.INCREASE);
- long time =
- RateFunctionValidation.readRequiredTime(
- arguments[1], position, RateFunctionType.INCREASE, 2);
- long currentWindowStart =
- RateFunctionValidation.readRequiredTime(
- arguments[2], position, RateFunctionType.INCREASE, 3);
- long currentWindowEnd =
- RateFunctionValidation.readRequiredTime(
- arguments[3], position, RateFunctionType.INCREASE, 4);
- RateFunctionValidation.validateWindow(
- RateFunctionType.INCREASE, time, currentWindowStart,
currentWindowEnd);
- initializeOrValidateWindow(currentWindowStart, currentWindowEnd);
- update(time, value);
- }
+ TypeServices.RATE_INPUT_SERVICE
Review Comment:
OrderedIncreaseAccumulator now dispatches to a native batch reader through
RATE_INPUT_SERVICE. It preserves value validation before time/window validation
and keeps the existing state update callback, including logical group positions
where applicable. RateBatchInputTest exercises all 16 implementations with
native and wrapped columns, masks/nulls and validation cases. This is one of
the 12 retained rate candidates; the other four were restored after
fixed-DOUBLE benchmarks showed regressions.
##########
iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/rate/OrderedRateAccumulator.java:
##########
@@ -57,27 +59,27 @@ public TableAccumulator copy() {
@Override
public void addInput(Column[] arguments, AggregationMask mask) {
RateFunctionValidation.validateArgumentCount(arguments,
RateFunctionType.RATE);
- int selectedCount = mask.getSelectedPositionCount();
- int[] selectedPositions = mask.isSelectAll() ? null :
mask.getSelectedPositions();
- for (int index = 0; index < selectedCount; index++) {
- int position = mask.isSelectAll() ? index : selectedPositions[index];
- if (arguments[0].isNull(position)) {
- continue;
- }
- double value =
- RateFunctionValidation.readValue(
- arguments[0], position, valueDataType, RateFunctionType.RATE);
- long time =
- RateFunctionValidation.readRequiredTime(arguments[1], position,
RateFunctionType.RATE, 2);
- long currentWindowStart =
- RateFunctionValidation.readRequiredTime(arguments[2], position,
RateFunctionType.RATE, 3);
- long currentWindowEnd =
- RateFunctionValidation.readRequiredTime(arguments[3], position,
RateFunctionType.RATE, 4);
- RateFunctionValidation.validateWindow(
- RateFunctionType.RATE, time, currentWindowStart, currentWindowEnd);
- initializeOrValidateWindow(currentWindowStart, currentWindowEnd);
- update(time, value);
- }
+ TypeServices.RATE_INPUT_SERVICE
Review Comment:
OrderedRateAccumulator now dispatches to a native batch reader through
RATE_INPUT_SERVICE. It preserves value validation before time/window validation
and keeps the existing state update callback, including logical group positions
where applicable. RateBatchInputTest exercises all 16 implementations with
native and wrapped columns, masks/nulls and validation cases. This is one of
the 12 retained rate candidates; the other four were restored after
fixed-DOUBLE benchmarks showed regressions.
##########
iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/rate/RateFunctionValidation.java:
##########
@@ -86,6 +79,25 @@ public static double readValue(
return value;
}
+ public static void validateValue(double value, RateFunctionType
functionType) {
Review Comment:
Expose the existing finite/nonnegative value checks to the typed batch
readers without changing exception order or messages. Keep readValue’s scalar
checks inline: replacing them with a helper changed the scalar benchmark
behavior on paths whose batch refactor was rejected. RateBatchInputTest covers
these validation semantics.
##########
iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/transformation/dag/column/unary/scalar/AbstractCastFunctionColumnTransformer.java:
##########
@@ -19,46 +19,40 @@
package org.apache.iotdb.calc.transformation.dag.column.unary.scalar;
-import org.apache.iotdb.calc.i18n.CalcMessages;
import org.apache.iotdb.calc.transformation.dag.column.ColumnTransformer;
import
org.apache.iotdb.calc.transformation.dag.column.unary.UnaryColumnTransformer;
-import org.apache.iotdb.calc.transformation.dag.util.CastFunctionUtils;
-import org.apache.iotdb.commons.exception.IoTDBRuntimeException;
-import org.apache.iotdb.commons.exception.SemanticException;
-import org.apache.iotdb.commons.queryengine.utils.DateTimeUtils;
+import org.apache.iotdb.calc.utils.TypeServices;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
-import org.apache.tsfile.common.conf.TSFileConfig;
import org.apache.tsfile.read.common.type.Type;
-import org.apache.tsfile.read.common.type.TypeEnum;
-import org.apache.tsfile.utils.Binary;
-import org.apache.tsfile.utils.BytesUtils;
-import org.apache.tsfile.utils.DateUtils;
import java.time.ZoneId;
-import java.time.format.DateTimeParseException;
-
-import static
org.apache.iotdb.calc.transformation.dag.util.CastFunctionUtils.ERROR_MSG;
-import static org.apache.iotdb.rpc.TSStatusCode.DATE_OUT_OF_RANGE;
public abstract class AbstractCastFunctionColumnTransformer extends
UnaryColumnTransformer {
private final ZoneId zoneId;
+ private final TypeServices.NumericCastBatch numericCastBatch;
+ private final TypeServices.CastInputService castInputService;
+ private final TypeServices.CastValueService castValueService;
protected AbstractCastFunctionColumnTransformer(
Type returnType, ColumnTransformer childColumnTransformer, ZoneId
zoneId) {
super(returnType, childColumnTransformer);
this.zoneId = zoneId;
+ this.numericCastBatch =
Review Comment:
Select the numeric source/target batch strategy once for CAST/TRY_CAST. The
16 INT32/INT64/FLOAT/DOUBLE pairs use native loops; other types keep the
existing conversion path. NumericCastBatchTest covers overflow, NaN,
null/selection, region and RLE inputs, including TRY_CAST null results. Local
mixed-type kernels improved 2.11–2.83x; fixed DOUBLE-to-DOUBLE was mostly
smaller gains or flat.
--
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]