> countMap = new HashMap<>();
<#if type.dataType != "boolean">
- private final int MAP_SIZE_THRESHOLD = IoTDBDescriptor.getInstance().getConfig().getModeMapSizeThreshold();
+ private final int MAP_SIZE_THRESHOLD = CommonDescriptor.getInstance().getConfig().getModeMapSizeThreshold();
#if>
@Override
diff --git a/iotdb-core/datanode/src/main/codegen/templates/constantFill.ftl b/iotdb-core/calc-commons/src/main/codegen/templates/constantFill.ftl
similarity index 90%
rename from iotdb-core/datanode/src/main/codegen/templates/constantFill.ftl
rename to iotdb-core/calc-commons/src/main/codegen/templates/constantFill.ftl
index 9ff15a150620c..88d01849ba95f 100644
--- a/iotdb-core/datanode/src/main/codegen/templates/constantFill.ftl
+++ b/iotdb-core/calc-commons/src/main/codegen/templates/constantFill.ftl
@@ -20,10 +20,10 @@
<#list allDataTypes.types as type>
<#assign className = "${type.dataType?cap_first}ConstantFill">
- <@pp.changeOutputFile name="/org/apache/iotdb/db/queryengine/execution/operator/process/fill/constant/${className}.java" />
-package org.apache.iotdb.db.queryengine.execution.operator.process.fill.constant;
+ <@pp.changeOutputFile name="/org/apache/iotdb/calc/execution/operator/process/fill/constant/${className}.java" />
+package org.apache.iotdb.calc.execution.operator.process.fill.constant;
-import org.apache.iotdb.db.queryengine.execution.operator.process.fill.IFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.IFill;
import org.apache.tsfile.read.common.block.column.${type.column};
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.read.common.block.column.RunLengthEncodedColumn;
diff --git a/iotdb-core/datanode/src/main/codegen/templates/linearFill.ftl b/iotdb-core/calc-commons/src/main/codegen/templates/linearFill.ftl
similarity index 94%
rename from iotdb-core/datanode/src/main/codegen/templates/linearFill.ftl
rename to iotdb-core/calc-commons/src/main/codegen/templates/linearFill.ftl
index f63b40bc3796e..301708018b6ac 100644
--- a/iotdb-core/datanode/src/main/codegen/templates/linearFill.ftl
+++ b/iotdb-core/calc-commons/src/main/codegen/templates/linearFill.ftl
@@ -21,8 +21,8 @@
<#list decimalDataTypes.types as type>
<#assign className = "${type.dataType?cap_first}LinearFill">
- <@pp.changeOutputFile name="/org/apache/iotdb/db/queryengine/execution/operator/process/fill/linear/${className}.java" />
-package org.apache.iotdb.db.queryengine.execution.operator.process.fill.linear;
+ <@pp.changeOutputFile name="/org/apache/iotdb/calc/execution/operator/process/fill/linear/${className}.java" />
+package org.apache.iotdb.calc.execution.operator.process.fill.linear;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.read.common.block.column.${type.column};
diff --git a/iotdb-core/datanode/src/main/codegen/templates/previousFill.ftl b/iotdb-core/calc-commons/src/main/codegen/templates/previousFill.ftl
similarity index 92%
rename from iotdb-core/datanode/src/main/codegen/templates/previousFill.ftl
rename to iotdb-core/calc-commons/src/main/codegen/templates/previousFill.ftl
index 8efa0bd0a7b26..e15f08935402d 100644
--- a/iotdb-core/datanode/src/main/codegen/templates/previousFill.ftl
+++ b/iotdb-core/calc-commons/src/main/codegen/templates/previousFill.ftl
@@ -21,10 +21,10 @@
<#list allDataTypes.types as type>
<#assign className = "${type.dataType?cap_first}PreviousFill">
- <@pp.changeOutputFile name="/org/apache/iotdb/db/queryengine/execution/operator/process/fill/previous/${className}.java" />
-package org.apache.iotdb.db.queryengine.execution.operator.process.fill.previous;
+ <@pp.changeOutputFile name="/org/apache/iotdb/calc/execution/operator/process/fill/previous/${className}.java" />
+package org.apache.iotdb.calc.execution.operator.process.fill.previous;
-import org.apache.iotdb.db.queryengine.execution.operator.process.fill.IFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.IFill;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.read.common.block.column.${type.column};
import org.apache.tsfile.read.common.block.column.${type.column}Builder;
diff --git a/iotdb-core/datanode/src/main/codegen/templates/previousFillWithTimeDuration.ftl b/iotdb-core/calc-commons/src/main/codegen/templates/previousFillWithTimeDuration.ftl
similarity index 92%
rename from iotdb-core/datanode/src/main/codegen/templates/previousFillWithTimeDuration.ftl
rename to iotdb-core/calc-commons/src/main/codegen/templates/previousFillWithTimeDuration.ftl
index 4de0b724357a5..22b0ff91efaf5 100644
--- a/iotdb-core/datanode/src/main/codegen/templates/previousFillWithTimeDuration.ftl
+++ b/iotdb-core/calc-commons/src/main/codegen/templates/previousFillWithTimeDuration.ftl
@@ -21,11 +21,11 @@
<#list allDataTypes.types as type>
<#assign className = "${type.dataType?cap_first}PreviousFillWithTimeDuration">
- <@pp.changeOutputFile name="/org/apache/iotdb/db/queryengine/execution/operator/process/fill/previous/${className}.java" />
-package org.apache.iotdb.db.queryengine.execution.operator.process.fill.previous;
+ <@pp.changeOutputFile name="/org/apache/iotdb/calc/execution/operator/process/fill/previous/${className}.java" />
+package org.apache.iotdb.calc.execution.operator.process.fill.previous;
-import org.apache.iotdb.db.queryengine.execution.operator.process.fill.IFill;
-import org.apache.iotdb.db.queryengine.execution.operator.process.fill.IFillFilter;
+import org.apache.iotdb.calc.execution.operator.process.fill.IFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.IFillFilter;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.read.common.block.column.${type.column};
import org.apache.tsfile.read.common.block.column.${type.column}Builder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/exception/MemoryNotEnoughException.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/exception/MemoryNotEnoughException.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/exception/MemoryNotEnoughException.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/exception/MemoryNotEnoughException.java
index 769399d51abd9..1a2924916dec9 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/exception/MemoryNotEnoughException.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/exception/MemoryNotEnoughException.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.exception;
+package org.apache.iotdb.calc.exception;
import org.apache.iotdb.commons.exception.IoTDBRuntimeException;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/exception/query/QueryProcessException.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/exception/QueryProcessException.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/exception/query/QueryProcessException.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/exception/QueryProcessException.java
index 08b6a61d06a53..3d9753c4275d1 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/exception/query/QueryProcessException.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/exception/QueryProcessException.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.exception.query;
+package org.apache.iotdb.calc.exception;
import org.apache.iotdb.commons.exception.IoTDBException;
import org.apache.iotdb.commons.exception.IoTDBRuntimeException;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/Accumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/aggregation/Accumulator.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/Accumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/aggregation/Accumulator.java
index a2599bc811eca..38b0c5353936d 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/Accumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/aggregation/Accumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.aggregation;
+package org.apache.iotdb.calc.execution.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/VarianceAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/aggregation/VarianceAccumulator.java
similarity index 99%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/VarianceAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/aggregation/VarianceAccumulator.java
index 8d27f1497e06d..48972749c3a27 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/VarianceAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/aggregation/VarianceAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.aggregation;
+package org.apache.iotdb.calc.execution.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/AbstractOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/AbstractOperator.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/AbstractOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/AbstractOperator.java
index 41d1f163f81ce..cc09d7fe971f6 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/AbstractOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/AbstractOperator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator;
+package org.apache.iotdb.calc.execution.operator;
import org.apache.tsfile.common.conf.TSFileDescriptor;
import org.apache.tsfile.read.common.block.TsBlock;
@@ -27,7 +27,7 @@
public abstract class AbstractOperator implements Operator {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractOperator.class);
- protected OperatorContext operatorContext;
+ protected CommonOperatorContext operatorContext;
protected long maxReturnSize =
TSFileDescriptor.getInstance().getConfig().getMaxTsBlockSizeInBytes();
@@ -104,7 +104,7 @@ public TsBlock getResultFromRetainedTsBlock() {
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
}
diff --git a/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/CommonOperatorContext.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/CommonOperatorContext.java
new file mode 100644
index 0000000000000..2c99fa5d77777
--- /dev/null
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/CommonOperatorContext.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.calc.execution.operator;
+
+import org.apache.iotdb.calc.plan.planner.memory.MemoryReservationManager;
+import org.apache.iotdb.commons.conf.CommonDescriptor;
+import org.apache.iotdb.commons.queryengine.plan.planner.plan.node.PlanNodeId;
+import org.apache.iotdb.commons.utils.TestOnly;
+
+import io.airlift.units.Duration;
+import org.apache.tsfile.utils.Accountable;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Contains common information about {@link Operator} execution.
+ *
+ * Not thread-safe.
+ */
+public abstract class CommonOperatorContext implements Accountable {
+
+ protected static Duration maxRunTime =
+ new Duration(
+ CommonDescriptor.getInstance().getConfig().getDriverTaskExecutionTimeSliceInMs(),
+ TimeUnit.MILLISECONDS);
+
+ protected final int operatorId;
+ // It seems it's never used.
+ protected final PlanNodeId planNodeId;
+ protected String operatorType;
+
+ protected long totalExecutionTimeInNanos = 0L;
+ protected long nextCalledCount = 0L;
+ protected long hasNextCalledCount = 0L;
+
+ // SpecifiedInfo is used to record some custom information for the operator,
+ // which will be shown in the result of EXPLAIN ANALYZE to analyze the query.
+ protected final Map specifiedInfo = new ConcurrentHashMap<>();
+ protected long output = 0;
+ protected long estimatedMemorySize;
+
+ protected CommonOperatorContext(int operatorId, PlanNodeId planNodeId, String operatorType) {
+ this.operatorId = operatorId;
+ this.planNodeId = planNodeId;
+ this.operatorType = operatorType;
+ }
+
+ public int getOperatorId() {
+ return operatorId;
+ }
+
+ public String getOperatorType() {
+ return operatorType;
+ }
+
+ public void setOperatorType(String operatorType) {
+ this.operatorType = operatorType;
+ }
+
+ public static Duration getMaxRunTime() {
+ return maxRunTime;
+ }
+
+ @TestOnly
+ public Duration getMaxRunTimeForTest() {
+ return maxRunTime;
+ }
+
+ public static void setMaxRunTime(Duration maxRunTime) {
+ CommonOperatorContext.maxRunTime = maxRunTime;
+ }
+
+ public PlanNodeId getPlanNodeId() {
+ return planNodeId;
+ }
+
+ public abstract MemoryReservationManager getMemoryReservationContext();
+
+ public abstract int getFragmentId();
+
+ public abstract int getPipelineId();
+
+ public void recordExecutionTime(long executionTimeInNanos) {
+ this.totalExecutionTimeInNanos += executionTimeInNanos;
+ }
+
+ public void recordNextCalled() {
+ this.nextCalledCount++;
+ }
+
+ public void recordHasNextCalled() {
+ this.hasNextCalledCount++;
+ }
+
+ public long getTotalExecutionTimeInNanos() {
+ return totalExecutionTimeInNanos;
+ }
+
+ public long getNextCalledCount() {
+ return nextCalledCount;
+ }
+
+ public long getHasNextCalledCount() {
+ return hasNextCalledCount;
+ }
+
+ public void setEstimatedMemorySize(long estimatedMemorySize) {
+ this.estimatedMemorySize = estimatedMemorySize;
+ }
+
+ public long getEstimatedMemorySize() {
+ return estimatedMemorySize;
+ }
+
+ public void addOutputRows(long outputRows) {
+ this.output += outputRows;
+ }
+
+ public long getOutputRows() {
+ return output;
+ }
+
+ public void recordSpecifiedInfo(String key, String value) {
+ specifiedInfo.put(key, value);
+ }
+
+ public Map getSpecifiedInfo() {
+ return specifiedInfo;
+ }
+}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/GroupedTopNBuilder.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/GroupedTopNBuilder.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/GroupedTopNBuilder.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/GroupedTopNBuilder.java
index 2f8a99097c95c..7911865076661 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/GroupedTopNBuilder.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/GroupedTopNBuilder.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator;
+package org.apache.iotdb.calc.execution.operator;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/GroupedTopNRowNumberAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/GroupedTopNRowNumberAccumulator.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/GroupedTopNRowNumberAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/GroupedTopNRowNumberAccumulator.java
index 81a489dccc0b1..284e325ff5aed 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/GroupedTopNRowNumberAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/GroupedTopNRowNumberAccumulator.java
@@ -17,11 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator;
+package org.apache.iotdb.calc.execution.operator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.LongBigArrayFIFOQueue;
-import org.apache.iotdb.db.utils.HeapTraversal;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.LongBigArrayFIFOQueue;
+import org.apache.iotdb.calc.utils.HeapTraversal;
import org.apache.tsfile.read.common.block.TsBlock;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/GroupedTopNRowNumberBuilder.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/GroupedTopNRowNumberBuilder.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/GroupedTopNRowNumberBuilder.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/GroupedTopNRowNumberBuilder.java
index 172adc82bc9fb..78c01ef14c071 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/GroupedTopNRowNumberBuilder.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/GroupedTopNRowNumberBuilder.java
@@ -17,10 +17,10 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator;
+package org.apache.iotdb.calc.execution.operator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.hash.GroupByHash;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
+import org.apache.iotdb.commons.queryengine.execution.operator.source.relational.aggregation.grouped.hash.GroupByHash;
import com.google.common.collect.AbstractIterator;
import com.google.common.collect.ImmutableList;
@@ -35,7 +35,7 @@
import java.util.Iterator;
import java.util.List;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.AbstractTableScanOperator.TIME_COLUMN_TEMPLATE;
+import static org.apache.iotdb.calc.plan.planner.CommonOperatorUtils.TIME_COLUMN_TEMPLATE;
public class GroupedTopNRowNumberBuilder implements GroupedTopNBuilder {
private static final long INSTANCE_SIZE =
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/IdRegistry.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/IdRegistry.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/IdRegistry.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/IdRegistry.java
index 35661335ca9cf..bb5abd17dddc9 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/IdRegistry.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/IdRegistry.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator;
+package org.apache.iotdb.calc.execution.operator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.IntArrayFIFOQueue;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.IntArrayFIFOQueue;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/Operator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/Operator.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/Operator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/Operator.java
index c0aeeb967b1b7..a2c937e0bb7c3 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/Operator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/Operator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator;
+package org.apache.iotdb.calc.execution.operator;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.read.common.block.TsBlock;
@@ -29,7 +29,7 @@ public interface Operator extends AutoCloseable, Accountable {
ListenableFuture> NOT_BLOCKED = immediateVoidFuture();
- OperatorContext getOperatorContext();
+ CommonOperatorContext getOperatorContext();
/**
* Returns a future that will be completed when the operator becomes unblocked. If the operator is
@@ -41,7 +41,7 @@ default ListenableFuture> isBlocked() {
}
default TsBlock nextWithTimer() throws Exception {
- OperatorContext context = getOperatorContext();
+ CommonOperatorContext context = getOperatorContext();
long startTime = System.nanoTime();
TsBlock output = null;
try {
@@ -65,7 +65,7 @@ default TsBlock nextWithTimer() throws Exception {
TsBlock next() throws Exception;
default boolean hasNextWithTimer() throws Exception {
- OperatorContext context = getOperatorContext();
+ CommonOperatorContext context = getOperatorContext();
long startTime = System.nanoTime();
try {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/RowIdComparisonStrategy.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/RowIdComparisonStrategy.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/RowIdComparisonStrategy.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/RowIdComparisonStrategy.java
index a3a49e7eef333..02b28466efa7b 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/RowIdComparisonStrategy.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/RowIdComparisonStrategy.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator;
+package org.apache.iotdb.calc.execution.operator;
public interface RowIdComparisonStrategy {
int compare(long leftRowId, long rightRowId);
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/RowIdHashStrategy.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/RowIdHashStrategy.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/RowIdHashStrategy.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/RowIdHashStrategy.java
index f51912c952d4c..984efa9a96cf1 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/RowIdHashStrategy.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/RowIdHashStrategy.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator;
+package org.apache.iotdb.calc.execution.operator;
/** Hash strategy that evaluates over row IDs */
public interface RowIdHashStrategy {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/RowReference.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/RowReference.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/RowReference.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/RowReference.java
index ef81b2ad992f0..b56c9f8983fa8 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/RowReference.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/RowReference.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator;
+package org.apache.iotdb.calc.execution.operator;
/**
* Reference to a row.
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/RowReferenceTsBlockManager.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/RowReferenceTsBlockManager.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/RowReferenceTsBlockManager.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/RowReferenceTsBlockManager.java
index ce6868eb55c75..dd81ab2f55f7b 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/RowReferenceTsBlockManager.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/RowReferenceTsBlockManager.java
@@ -17,10 +17,10 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator;
+package org.apache.iotdb.calc.execution.operator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.IntBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.LongBigArrayFIFOQueue;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.IntBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.LongBigArrayFIFOQueue;
import org.apache.tsfile.read.common.block.TsBlock;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/SimpleTsBlockWithPositionComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/SimpleTsBlockWithPositionComparator.java
similarity index 83%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/SimpleTsBlockWithPositionComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/SimpleTsBlockWithPositionComparator.java
index ad0b1af9523d5..8cab1352032a2 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/SimpleTsBlockWithPositionComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/SimpleTsBlockWithPositionComparator.java
@@ -17,12 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator;
+package org.apache.iotdb.calc.execution.operator;
-import org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.MergeSortComparator;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.SortOrder;
-import org.apache.iotdb.db.utils.datastructure.MergeSortKey;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.execution.operator.process.join.merge.MergeSortComparator;
+import org.apache.iotdb.calc.utils.datastructure.MergeSortKey;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.SortOrder;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/TsBlockWithPositionComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/TsBlockWithPositionComparator.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/TsBlockWithPositionComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/TsBlockWithPositionComparator.java
index aa6c5bfb734a9..e8b50d7ab739c 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/TsBlockWithPositionComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/TsBlockWithPositionComparator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator;
+package org.apache.iotdb.calc.execution.operator;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AbstractConsumeAllOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/AbstractConsumeAllOperator.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AbstractConsumeAllOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/AbstractConsumeAllOperator.java
index 636102a015af4..c774023ca90dd 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AbstractConsumeAllOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/AbstractConsumeAllOperator.java
@@ -17,11 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.operator.AbstractOperator;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
+import org.apache.iotdb.calc.execution.operator.AbstractOperator;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.read.common.block.TsBlock;
@@ -50,7 +50,8 @@ public abstract class AbstractConsumeAllOperator extends AbstractOperator
/** Indicate whether we found an empty child input in one loop */
protected boolean hasEmptyChildInput = false;
- protected AbstractConsumeAllOperator(OperatorContext operatorContext, List children) {
+ protected AbstractConsumeAllOperator(
+ CommonOperatorContext operatorContext, List children) {
this.operatorContext = operatorContext;
this.children = children;
this.inputOperatorsCount = children.size();
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AbstractFillOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/AbstractFillOperator.java
similarity index 84%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AbstractFillOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/AbstractFillOperator.java
index 1cd09143e90a1..e354c6e9e628a 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AbstractFillOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/AbstractFillOperator.java
@@ -17,12 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.fill.IFill;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.fill.IFill;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.block.column.Column;
@@ -33,16 +33,17 @@
import static java.util.Objects.requireNonNull;
/** Used for previous and constant value fill. */
-abstract class AbstractFillOperator implements ProcessOperator {
+public abstract class AbstractFillOperator implements ProcessOperator {
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(AbstractFillOperator.class);
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
private final IFill[] fillArray;
private final Operator child;
private final int outputColumnCount;
- AbstractFillOperator(OperatorContext operatorContext, IFill[] fillArray, Operator child) {
+ protected AbstractFillOperator(
+ CommonOperatorContext operatorContext, IFill[] fillArray, Operator child) {
this.operatorContext = requireNonNull(operatorContext, "operatorContext is null");
checkArgument(
fillArray != null && fillArray.length > 0, "fillArray should not be null or empty");
@@ -52,7 +53,7 @@ abstract class AbstractFillOperator implements ProcessOperator {
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
@@ -82,7 +83,7 @@ public TsBlock next() throws Exception {
block.getPositionCount(), block.getTimeColumn(), valueColumns);
}
- abstract Column getHelperColumn(TsBlock tsBlock);
+ protected abstract Column getHelperColumn(TsBlock tsBlock);
@Override
public boolean hasNext() throws Exception {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AbstractLinearFillOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/AbstractLinearFillOperator.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AbstractLinearFillOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/AbstractLinearFillOperator.java
index e78fed485cf6a..2e523d1bf4c4e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AbstractLinearFillOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/AbstractLinearFillOperator.java
@@ -17,12 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.fill.ILinearFill;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.fill.ILinearFill;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.block.column.Column;
@@ -36,11 +36,11 @@
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
-abstract class AbstractLinearFillOperator implements ProcessOperator {
+public abstract class AbstractLinearFillOperator implements ProcessOperator {
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(AbstractLinearFillOperator.class);
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
protected final ILinearFill[] fillArray;
private final Operator child;
protected final int outputColumnCount;
@@ -63,8 +63,8 @@ abstract class AbstractLinearFillOperator implements ProcessOperator {
// indicate whether there is more TsBlock for child operator
protected boolean noMoreTsBlock;
- AbstractLinearFillOperator(
- OperatorContext operatorContext, ILinearFill[] fillArray, Operator child) {
+ protected AbstractLinearFillOperator(
+ CommonOperatorContext operatorContext, ILinearFill[] fillArray, Operator child) {
this.operatorContext = requireNonNull(operatorContext, "operatorContext is null");
checkArgument(
fillArray != null && fillArray.length > 0, "fillArray should not be null or empty");
@@ -81,7 +81,7 @@ abstract class AbstractLinearFillOperator implements ProcessOperator {
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
@@ -155,10 +155,10 @@ boolean noMoreTsBlockForCurrentGroup() {
return noMoreTsBlock;
}
- abstract Column getHelperColumn(TsBlock tsBlock);
+ protected abstract Column getHelperColumn(TsBlock tsBlock);
// -1 means all values of helper column in @param{tsBlock} are null
- abstract Integer getLastRowIndexForNonNullHelperColumn(TsBlock tsBlock);
+ protected abstract Integer getLastRowIndexForNonNullHelperColumn(TsBlock tsBlock);
TsBlock append(int length, Column timeColumn, Column[] valueColumns) {
return new TsBlock(length, timeColumn, valueColumns);
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AbstractSortOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/AbstractSortOperator.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AbstractSortOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/AbstractSortOperator.java
index 73aea0e32e688..82d0b94b33476 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AbstractSortOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/AbstractSortOperator.java
@@ -17,19 +17,19 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
-
+package org.apache.iotdb.calc.execution.operator.process;
+
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.utils.datastructure.MergeSortHeap;
+import org.apache.iotdb.calc.utils.datastructure.MergeSortKey;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.utils.sort.DiskSpiller;
+import org.apache.iotdb.calc.utils.sort.MemoryReader;
+import org.apache.iotdb.calc.utils.sort.SortBufferManager;
+import org.apache.iotdb.calc.utils.sort.SortReader;
+import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.iotdb.commons.exception.IoTDBException;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.utils.datastructure.MergeSortHeap;
-import org.apache.iotdb.db.utils.datastructure.MergeSortKey;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
-import org.apache.iotdb.db.utils.sort.DiskSpiller;
-import org.apache.iotdb.db.utils.sort.MemoryReader;
-import org.apache.iotdb.db.utils.sort.SortBufferManager;
-import org.apache.iotdb.db.utils.sort.SortReader;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.block.column.ColumnBuilder;
@@ -51,7 +51,7 @@ public abstract class AbstractSortOperator implements ProcessOperator {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractSortOperator.class);
- protected final OperatorContext operatorContext;
+ protected final CommonOperatorContext operatorContext;
protected final Operator inputOperator;
protected final TsBlockBuilder tsBlockBuilder;
@@ -80,7 +80,7 @@ public abstract class AbstractSortOperator implements ProcessOperator {
private long sortCost = 0;
AbstractSortOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator inputOperator,
List dataTypes,
DiskSpiller diskSpiller,
@@ -95,7 +95,7 @@ public abstract class AbstractSortOperator implements ProcessOperator {
this.sortBufferManager =
new SortBufferManager(
TSFileDescriptor.getInstance().getConfig().getMaxTsBlockSizeInBytes(),
- IoTDBDescriptor.getInstance().getConfig().getSortBufferSize());
+ CommonDescriptor.getInstance().getConfig().getSortBufferSize());
}
protected void buildResult() throws IoTDBException {
@@ -119,7 +119,7 @@ protected void buildResult() throws IoTDBException {
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AggregationMergeSortOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/AggregationMergeSortOperator.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AggregationMergeSortOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/AggregationMergeSortOperator.java
index f67975d84fbd6..6f106d680df4e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AggregationMergeSortOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/AggregationMergeSortOperator.java
@@ -17,15 +17,15 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.aggregation.Accumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.utils.datastructure.MergeSortHeap;
-import org.apache.iotdb.db.utils.datastructure.MergeSortKey;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.execution.aggregation.Accumulator;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.utils.datastructure.MergeSortHeap;
+import org.apache.iotdb.calc.utils.datastructure.MergeSortKey;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.block.column.Column;
@@ -69,7 +69,7 @@ public class AggregationMergeSortOperator extends AbstractConsumeAllOperator {
private long lastTime;
public AggregationMergeSortOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
List children,
List dataTypes,
List accumulators,
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AssignUniqueIdOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/AssignUniqueIdOperator.java
similarity index 85%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AssignUniqueIdOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/AssignUniqueIdOperator.java
index 5501764482d38..f7faaadc0a519 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AssignUniqueIdOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/AssignUniqueIdOperator.java
@@ -17,12 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.schedule.task.DriverTaskId;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.block.column.Column;
@@ -43,7 +42,7 @@ public class AssignUniqueIdOperator implements ProcessOperator {
private static final long ROW_IDS_PER_REQUEST = 1L << 20L;
private static final long MAX_ROW_ID = 1L << 40L;
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
private final Operator child;
private final AtomicLong rowIdPool = new AtomicLong();
@@ -52,13 +51,13 @@ public class AssignUniqueIdOperator implements ProcessOperator {
private long rowIdCounter;
private long maxRowIdCounterValue;
- public AssignUniqueIdOperator(OperatorContext operatorContext, Operator child) {
+ public AssignUniqueIdOperator(CommonOperatorContext operatorContext, Operator child) {
this.operatorContext = operatorContext;
this.child = child;
- DriverTaskId id = operatorContext.getDriverContext().getDriverTaskID();
this.uniqueValueMask =
- (((long) id.getFragmentId().getId()) << 54) | (((long) id.getPipelineId()) << 40);
+ (((long) operatorContext.getFragmentId()) << 54)
+ | (((long) operatorContext.getPipelineId()) << 40);
requestValues();
}
@@ -117,7 +116,7 @@ public long ramBytesUsed() {
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/CollectOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/CollectOperator.java
similarity index 88%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/CollectOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/CollectOperator.java
index 668cf193de97f..921d273d04e8a 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/CollectOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/CollectOperator.java
@@ -17,12 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import org.apache.iotdb.commons.utils.TestOnly;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.read.common.block.TsBlock;
@@ -34,13 +34,13 @@ public class CollectOperator implements ProcessOperator {
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(CollectOperator.class);
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
protected final List children;
private boolean inited = false;
protected int currentIndex;
- public CollectOperator(OperatorContext operatorContext, List children) {
+ public CollectOperator(CommonOperatorContext operatorContext, List children) {
this.operatorContext = operatorContext;
this.children = children;
this.currentIndex = 0;
@@ -87,7 +87,7 @@ public boolean isFinished() throws Exception {
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/EnforceSingleRowOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/EnforceSingleRowOperator.java
similarity index 87%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/EnforceSingleRowOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/EnforceSingleRowOperator.java
index 9438d96dc3057..6a300c2cdfe64 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/EnforceSingleRowOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/EnforceSingleRowOperator.java
@@ -17,12 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.commons.exception.SemanticException;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.common.conf.TSFileDescriptor;
@@ -38,12 +38,12 @@ public class EnforceSingleRowOperator implements ProcessOperator {
private static final String NO_RESULT_ERROR_MESSAGE = "Scalar sub-query does not have output.";
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
private final Operator child;
private boolean finished = false;
- public EnforceSingleRowOperator(OperatorContext operatorContext, Operator child) {
+ public EnforceSingleRowOperator(CommonOperatorContext operatorContext, Operator child) {
this.operatorContext = operatorContext;
this.child = child;
}
@@ -117,7 +117,7 @@ public long ramBytesUsed() {
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/FilterAndProjectOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/FilterAndProjectOperator.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/FilterAndProjectOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/FilterAndProjectOperator.java
index 83e493f622054..16e0cd7b33069 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/FilterAndProjectOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/FilterAndProjectOperator.java
@@ -17,21 +17,21 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
-
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.AbstractCaseWhenThenColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.FailFunctionColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.binary.BinaryColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.leaf.IdentityColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.leaf.LeafColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.multi.MappableUDFColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.multi.MultiColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.ternary.TernaryColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.UnaryColumnTransformer;
+package org.apache.iotdb.calc.execution.operator.process;
+
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.transformation.dag.column.AbstractCaseWhenThenColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.FailFunctionColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.binary.BinaryColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.leaf.IdentityColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.leaf.LeafColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.multi.MappableUDFColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.multi.MultiColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.ternary.TernaryColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.UnaryColumnTransformer;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.block.column.Column;
@@ -70,7 +70,7 @@ public class FilterAndProjectOperator implements ProcessOperator {
private final boolean hasNonMappableUDF;
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
// false when we only need to do projection
private final boolean hasFilter;
@@ -79,7 +79,7 @@ public class FilterAndProjectOperator implements ProcessOperator {
@SuppressWarnings("squid:S107")
public FilterAndProjectOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator inputOperator,
List filterOutputDataTypes,
List filterLeafColumnTransformerList,
@@ -117,7 +117,7 @@ public FilterAndProjectOperator(
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/LimitOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/LimitOperator.java
similarity index 87%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/LimitOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/LimitOperator.java
index 85ef22ababd34..9f21dcf86a66b 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/LimitOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/LimitOperator.java
@@ -17,11 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.read.common.block.TsBlock;
@@ -34,11 +34,11 @@ public class LimitOperator implements ProcessOperator {
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(LimitOperator.class);
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
private long remainingLimit;
private final Operator child;
- public LimitOperator(OperatorContext operatorContext, long limit, Operator child) {
+ public LimitOperator(CommonOperatorContext operatorContext, long limit, Operator child) {
this.operatorContext = requireNonNull(operatorContext, "operatorContext is null");
checkArgument(limit >= 0, "limit must be at least zero");
this.remainingLimit = limit;
@@ -52,7 +52,7 @@ public LimitOperator(LimitOperator limitOperator, Operator child) {
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/MappingCollectOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/MappingCollectOperator.java
similarity index 83%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/MappingCollectOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/MappingCollectOperator.java
index 886dba305b7b3..8bc1c18e9e66a 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/MappingCollectOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/MappingCollectOperator.java
@@ -17,11 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.read.common.block.TsBlock;
@@ -40,7 +40,9 @@ public class MappingCollectOperator extends CollectOperator {
private final int outputColumnsCount;
public MappingCollectOperator(
- OperatorContext operatorContext, List children, List> mappings) {
+ CommonOperatorContext operatorContext,
+ List children,
+ List> mappings) {
super(operatorContext, children);
this.mappings = mappings;
outputColumnsCount = mappings.get(0).size();
@@ -61,7 +63,7 @@ public TsBlock next() throws Exception {
return TsBlock.wrapBlocksWithoutCopy(
tsBlock.getPositionCount(),
new RunLengthEncodedColumn(
- TableScanOperator.TIME_COLUMN_TEMPLATE, tsBlock.getPositionCount()),
+ CommonOperatorUtils.TIME_COLUMN_TEMPLATE, tsBlock.getPositionCount()),
columns);
}
} else {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/MergeSortOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/MergeSortOperator.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/MergeSortOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/MergeSortOperator.java
index 813217872aead..613d3f549d722 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/MergeSortOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/MergeSortOperator.java
@@ -17,14 +17,14 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.utils.datastructure.MergeSortHeap;
-import org.apache.iotdb.db.utils.datastructure.MergeSortKey;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.utils.datastructure.MergeSortHeap;
+import org.apache.iotdb.calc.utils.datastructure.MergeSortKey;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.block.column.ColumnBuilder;
@@ -55,8 +55,8 @@ public abstract class MergeSortOperator extends AbstractConsumeAllOperator {
private boolean finished;
- MergeSortOperator(
- OperatorContext operatorContext,
+ protected MergeSortOperator(
+ CommonOperatorContext operatorContext,
List inputOperators,
List dataTypes,
Comparator comparator) {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/OffsetOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/OffsetOperator.java
similarity index 87%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/OffsetOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/OffsetOperator.java
index 24fc72d094177..376f3d9d2215a 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/OffsetOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/OffsetOperator.java
@@ -17,11 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.read.common.block.TsBlock;
@@ -34,11 +34,11 @@ public class OffsetOperator implements ProcessOperator {
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(OffsetOperator.class);
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
private long remainingOffset;
private final Operator child;
- public OffsetOperator(OperatorContext operatorContext, long offset, Operator child) {
+ public OffsetOperator(CommonOperatorContext operatorContext, long offset, Operator child) {
this.operatorContext = requireNonNull(operatorContext, "operatorContext is null");
checkArgument(offset >= 0, "offset must be at least zero");
this.remainingOffset = offset;
@@ -52,7 +52,7 @@ public OffsetOperator(OffsetOperator offsetOperator, Operator child) {
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/PatternRecognitionOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/PatternRecognitionOperator.java
similarity index 89%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/PatternRecognitionOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/PatternRecognitionOperator.java
index 0275b44e1459a..d0ee968c0e569 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/PatternRecognitionOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/PatternRecognitionOperator.java
@@ -17,21 +17,21 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
-
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.LogicalIndexNavigation;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.PatternAggregator;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.PatternPartitionExecutor;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.PatternVariableRecognizer;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.expression.PatternExpressionComputation;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher.Matcher;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.utils.RowComparator;
-import org.apache.iotdb.db.queryengine.plan.planner.memory.MemoryReservationManager;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.node.RowsPerMatch;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.node.SkipToPosition;
+package org.apache.iotdb.calc.execution.operator.process;
+
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.LogicalIndexNavigation;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.PatternAggregator;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.PatternPartitionExecutor;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.PatternVariableRecognizer;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.expression.PatternExpressionComputation;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher.Matcher;
+import org.apache.iotdb.calc.execution.operator.process.window.utils.RowComparator;
+import org.apache.iotdb.calc.plan.planner.memory.MemoryReservationManager;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.RowsPerMatch;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.SkipToPosition;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture;
@@ -50,15 +50,15 @@
import java.util.Optional;
import java.util.concurrent.TimeUnit;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.AbstractTableScanOperator.TIME_COLUMN_TEMPLATE;
-import static org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanGraphPrinter.MAX_RESERVED_MEMORY;
+import static org.apache.iotdb.calc.plan.planner.CommonOperatorUtils.MAX_RESERVED_MEMORY;
+import static org.apache.iotdb.calc.plan.planner.CommonOperatorUtils.TIME_COLUMN_TEMPLATE;
public class PatternRecognitionOperator implements ProcessOperator {
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(PatternRecognitionOperator.class);
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
private final Operator child;
private final List inputDataTypes;
private final List outputChannels;
@@ -93,7 +93,7 @@ public class PatternRecognitionOperator implements ProcessOperator {
private final long maxRuntime;
public PatternRecognitionOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator child,
List inputDataTypes,
List outputDataTypes,
@@ -145,15 +145,11 @@ public PatternRecognitionOperator(
this.maxRuntime = this.operatorContext.getMaxRunTime().roundTo(TimeUnit.NANOSECONDS);
this.totalMemorySize = 0;
this.maxUsedMemory = 0;
- this.memoryReservationManager =
- operatorContext
- .getDriverContext()
- .getFragmentInstanceContext()
- .getMemoryReservationContext();
+ this.memoryReservationManager = operatorContext.getMemoryReservationContext();
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/PreviousFillWithGroupOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/PreviousFillWithGroupOperator.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/PreviousFillWithGroupOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/PreviousFillWithGroupOperator.java
index ca5af889937e0..06f1d63547001 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/PreviousFillWithGroupOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/PreviousFillWithGroupOperator.java
@@ -17,13 +17,13 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.fill.IFill;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.fill.IFill;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.block.column.Column;
@@ -44,7 +44,7 @@ public class PreviousFillWithGroupOperator implements ProcessOperator {
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(PreviousFillWithGroupOperator.class);
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
private final IFill[] fillArray;
private final Operator child;
private final int outputColumnCount;
@@ -59,7 +59,7 @@ public class PreviousFillWithGroupOperator implements ProcessOperator {
private SortKey lastRow = null;
public PreviousFillWithGroupOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
IFill[] fillArray,
Operator child,
int helperColumnIndex,
@@ -166,7 +166,7 @@ public ListenableFuture> isBlocked() {
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/ProcessOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/ProcessOperator.java
similarity index 86%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/ProcessOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/ProcessOperator.java
index 55c61f33f8af2..22462a5544644 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/ProcessOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/ProcessOperator.java
@@ -17,8 +17,8 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.Operator;
public interface ProcessOperator extends Operator {}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/SortOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/SortOperator.java
similarity index 85%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/SortOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/SortOperator.java
index 31029a30da640..0b546eee70216 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/SortOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/SortOperator.java
@@ -17,14 +17,14 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.utils.sort.DiskSpiller;
import org.apache.iotdb.commons.exception.IoTDBException;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
-import org.apache.iotdb.db.utils.sort.DiskSpiller;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.read.common.block.TsBlock;
@@ -39,8 +39,8 @@ public abstract class SortOperator extends AbstractSortOperator {
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(SortOperator.class);
- SortOperator(
- OperatorContext operatorContext,
+ protected SortOperator(
+ CommonOperatorContext operatorContext,
Operator inputOperator,
List dataTypes,
DiskSpiller diskSpiller,
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableFillOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableFillOperator.java
similarity index 78%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableFillOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableFillOperator.java
index dd55e6ca4905d..5b41bb657de18 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableFillOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableFillOperator.java
@@ -17,11 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.fill.IFill;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.fill.IFill;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.read.common.block.TsBlock;
@@ -34,13 +34,16 @@ public class TableFillOperator extends AbstractFillOperator {
private final int helperColumnIndex;
public TableFillOperator(
- OperatorContext operatorContext, IFill[] fillArray, Operator child, int helperColumnIndex) {
+ CommonOperatorContext operatorContext,
+ IFill[] fillArray,
+ Operator child,
+ int helperColumnIndex) {
super(operatorContext, fillArray, child);
this.helperColumnIndex = helperColumnIndex;
}
@Override
- Column getHelperColumn(TsBlock tsBlock) {
+ protected Column getHelperColumn(TsBlock tsBlock) {
// if helperColumnIndex is -1, HelperColumn won't be used, so just return TimeColumn in TsBlock
// instead
return helperColumnIndex == -1 ? tsBlock.getTimeColumn() : tsBlock.getColumn(helperColumnIndex);
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableLinearFillOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableLinearFillOperator.java
similarity index 81%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableLinearFillOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableLinearFillOperator.java
index cb51a26057feb..b0f75ef4b29ee 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableLinearFillOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableLinearFillOperator.java
@@ -17,11 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.fill.ILinearFill;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.fill.ILinearFill;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.read.common.block.TsBlock;
@@ -33,7 +33,7 @@ public class TableLinearFillOperator extends AbstractLinearFillOperator {
private final int helperColumnIndex;
public TableLinearFillOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
ILinearFill[] fillArray,
Operator child,
int helperColumnIndex) {
@@ -42,14 +42,14 @@ public TableLinearFillOperator(
}
@Override
- Column getHelperColumn(TsBlock tsBlock) {
+ protected Column getHelperColumn(TsBlock tsBlock) {
// if helperColumnIndex is -1, HelperColumn won't be used, so just return TimeColumn in TsBlock
// instead
return tsBlock.getColumn(helperColumnIndex);
}
@Override
- Integer getLastRowIndexForNonNullHelperColumn(TsBlock tsBlock) {
+ protected Integer getLastRowIndexForNonNullHelperColumn(TsBlock tsBlock) {
Column helperColumn = getHelperColumn(tsBlock);
int size = tsBlock.getPositionCount();
if (!helperColumn.mayHaveNull()) {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableLinearFillWithGroupOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableLinearFillWithGroupOperator.java
similarity index 90%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableLinearFillWithGroupOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableLinearFillWithGroupOperator.java
index b9fb7c095b1b4..883ee156edccd 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableLinearFillWithGroupOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableLinearFillWithGroupOperator.java
@@ -17,12 +17,13 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.fill.ILinearFill;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.fill.ILinearFill;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
@@ -35,8 +36,6 @@
import java.util.Comparator;
import java.util.List;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator.TIME_COLUMN_TEMPLATE;
-
public class TableLinearFillWithGroupOperator extends TableLinearFillOperator {
private final List groupSplitter;
@@ -50,7 +49,7 @@ public class TableLinearFillWithGroupOperator extends TableLinearFillOperator {
private SortKey lastRow = null;
public TableLinearFillWithGroupOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
ILinearFill[] fillArray,
Operator child,
int helperColumnIndex,
@@ -86,7 +85,8 @@ TsBlock buildFinalResult(TsBlock tempResult) {
TsBlock result = null;
if (!resultBuilder.isEmpty()) {
Column timeColumn =
- new RunLengthEncodedColumn(TIME_COLUMN_TEMPLATE, resultBuilder.getPositionCount());
+ new RunLengthEncodedColumn(
+ CommonOperatorUtils.TIME_COLUMN_TEMPLATE, resultBuilder.getPositionCount());
result = resultBuilder.build(timeColumn);
resultBuilder.reset();
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableMergeSortOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableMergeSortOperator.java
similarity index 76%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableMergeSortOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableMergeSortOperator.java
index 0a7616db38ead..136747151a718 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableMergeSortOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableMergeSortOperator.java
@@ -17,11 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.read.common.block.TsBlock;
@@ -32,11 +33,9 @@
import java.util.Comparator;
import java.util.List;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator.TIME_COLUMN_TEMPLATE;
-
public class TableMergeSortOperator extends MergeSortOperator {
public TableMergeSortOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
List inputOperators,
List dataTypes,
Comparator comparator) {
@@ -51,6 +50,7 @@ protected void appendTime(TimeColumnBuilder timeBuilder, long time) {
@Override
protected TsBlock buildResult(TsBlockBuilder resultBuilder) {
return resultBuilder.build(
- new RunLengthEncodedColumn(TIME_COLUMN_TEMPLATE, resultBuilder.getPositionCount()));
+ new RunLengthEncodedColumn(
+ CommonOperatorUtils.TIME_COLUMN_TEMPLATE, resultBuilder.getPositionCount()));
}
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableSortOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableSortOperator.java
similarity index 75%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableSortOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableSortOperator.java
index 6d01819e756d2..b09b3cb5b56ec 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableSortOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableSortOperator.java
@@ -17,12 +17,13 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
-import org.apache.iotdb.db.utils.sort.TableDiskSpiller;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.utils.sort.TableDiskSpiller;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.read.common.block.TsBlock;
@@ -33,11 +34,9 @@
import java.util.Comparator;
import java.util.List;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator.TIME_COLUMN_TEMPLATE;
-
public class TableSortOperator extends SortOperator {
public TableSortOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator inputOperator,
List dataTypes,
String folderPath,
@@ -58,6 +57,7 @@ protected void appendTime(TimeColumnBuilder timeBuilder, long time) {
@Override
protected TsBlock buildFinalResult(TsBlockBuilder resultBuilder) {
return resultBuilder.build(
- new RunLengthEncodedColumn(TIME_COLUMN_TEMPLATE, resultBuilder.getPositionCount()));
+ new RunLengthEncodedColumn(
+ CommonOperatorUtils.TIME_COLUMN_TEMPLATE, resultBuilder.getPositionCount()));
}
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableStreamSortOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableStreamSortOperator.java
similarity index 91%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableStreamSortOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableStreamSortOperator.java
index 90565a8587592..a1cb2c7321692 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableStreamSortOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableStreamSortOperator.java
@@ -17,14 +17,15 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.utils.sort.TableDiskSpiller;
import org.apache.iotdb.commons.exception.IoTDBException;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
-import org.apache.iotdb.db.utils.sort.TableDiskSpiller;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.read.common.block.TsBlock;
@@ -35,8 +36,6 @@
import java.util.Comparator;
import java.util.List;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator.TIME_COLUMN_TEMPLATE;
-
public class TableStreamSortOperator extends AbstractSortOperator {
private static final long INSTANCE_SIZE =
@@ -61,7 +60,7 @@ public class TableStreamSortOperator extends AbstractSortOperator {
private SortKey lastRow = null;
public TableStreamSortOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator inputOperator,
List dataTypes,
String folderPath,
@@ -94,7 +93,8 @@ public TsBlock next() throws Exception {
if (tsBlockBuilder.isFull() || consumedUp()) {
int rowCount = tsBlockBuilder.getPositionCount();
TsBlock res =
- tsBlockBuilder.build(new RunLengthEncodedColumn(TIME_COLUMN_TEMPLATE, rowCount));
+ tsBlockBuilder.build(
+ new RunLengthEncodedColumn(CommonOperatorUtils.TIME_COLUMN_TEMPLATE, rowCount));
remainingCount -= rowCount;
tsBlockBuilder.reset();
return res;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableTopKOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableTopKOperator.java
similarity index 76%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableTopKOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableTopKOperator.java
index ca4a5ad5bebef..2a7d11657b7de 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TableTopKOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TableTopKOperator.java
@@ -17,11 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.enums.TSDataType;
@@ -31,11 +32,9 @@
import java.util.Comparator;
import java.util.List;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator.TIME_COLUMN_TEMPLATE;
-
public class TableTopKOperator extends TopKOperator {
public TableTopKOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
List childrenOperators,
List dataTypes,
Comparator comparator,
@@ -46,7 +45,9 @@ public TableTopKOperator(
@Override
protected TsBlock constrcutResultTsBlock(int positionCount, Column[] columns) {
- return new TsBlock(new RunLengthEncodedColumn(TIME_COLUMN_TEMPLATE, positionCount), columns);
+ return new TsBlock(
+ new RunLengthEncodedColumn(CommonOperatorUtils.TIME_COLUMN_TEMPLATE, positionCount),
+ columns);
}
@Override
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TopKOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TopKOperator.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TopKOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TopKOperator.java
index 0df7efdd19f0b..bdb424e15b812 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/TopKOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/TopKOperator.java
@@ -17,14 +17,14 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.utils.datastructure.MergeSortHeap;
-import org.apache.iotdb.db.utils.datastructure.MergeSortKey;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.utils.datastructure.MergeSortHeap;
+import org.apache.iotdb.calc.utils.datastructure.MergeSortKey;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.block.column.Column;
@@ -54,8 +54,8 @@
public abstract class TopKOperator implements ProcessOperator {
private static final long INSTANCE_SIZE =
- RamUsageEstimator.shallowSizeOfInstance(TreeTopKOperator.class);
- private final OperatorContext operatorContext;
+ RamUsageEstimator.shallowSizeOfInstance(TopKOperator.class);
+ private final CommonOperatorContext operatorContext;
private final List childrenOperators;
private int childIndex;
@@ -86,8 +86,8 @@ public abstract class TopKOperator implements ProcessOperator {
public static final int OPERATOR_BATCH_UPPER_BOUND = 100000;
- TopKOperator(
- OperatorContext operatorContext,
+ protected TopKOperator(
+ CommonOperatorContext operatorContext,
List childrenOperators,
List dataTypes,
Comparator comparator,
@@ -112,7 +112,7 @@ public abstract class TopKOperator implements ProcessOperator {
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/ValuesOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/ValuesOperator.java
similarity index 86%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/ValuesOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/ValuesOperator.java
index eeac35d918908..35ca8a4252f66 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/ValuesOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/ValuesOperator.java
@@ -17,11 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process;
+package org.apache.iotdb.calc.execution.operator.process;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture;
@@ -37,12 +37,12 @@ public class ValuesOperator implements Operator {
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(ValuesOperator.class);
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
private final Iterator tsBlocks;
private final long maxTsBlockSize;
private long currentRetainedSize;
- public ValuesOperator(OperatorContext operatorContext, List tsBlocks) {
+ public ValuesOperator(CommonOperatorContext operatorContext, List tsBlocks) {
this.operatorContext = requireNonNull(operatorContext, "operatorContext is null");
requireNonNull(tsBlocks, "tsBlocks is null");
@@ -61,7 +61,7 @@ public ValuesOperator(OperatorContext operatorContext, List tsBlocks) {
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/IFill.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/IFill.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/IFill.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/IFill.java
index 009c106541a77..1059a80799e54 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/IFill.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/IFill.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.fill;
+package org.apache.iotdb.calc.execution.operator.process.fill;
import org.apache.tsfile.block.column.Column;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/IFillFilter.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/IFillFilter.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/IFillFilter.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/IFillFilter.java
index 736be974cabe8..77e7436bb5849 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/IFillFilter.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/IFillFilter.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.fill;
+package org.apache.iotdb.calc.execution.operator.process.fill;
public interface IFillFilter {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/ILinearFill.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/ILinearFill.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/ILinearFill.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/ILinearFill.java
index 0dccba1054697..0a39604d8a045 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/ILinearFill.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/ILinearFill.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.fill;
+package org.apache.iotdb.calc.execution.operator.process.fill;
import org.apache.tsfile.block.column.Column;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/AbstractMonthIntervalFillFilter.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/filter/AbstractMonthIntervalFillFilter.java
similarity index 89%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/AbstractMonthIntervalFillFilter.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/filter/AbstractMonthIntervalFillFilter.java
index 24a629189ab53..c3805e121b502 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/AbstractMonthIntervalFillFilter.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/filter/AbstractMonthIntervalFillFilter.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.fill.filter;
+package org.apache.iotdb.calc.execution.operator.process.fill.filter;
-import org.apache.iotdb.db.queryengine.execution.operator.process.fill.IFillFilter;
+import org.apache.iotdb.calc.execution.operator.process.fill.IFillFilter;
import java.time.ZoneId;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/FixedIntervalFillFilter.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/filter/FixedIntervalFillFilter.java
similarity index 89%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/FixedIntervalFillFilter.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/filter/FixedIntervalFillFilter.java
index 840148438a7d2..8fbd4ce379d78 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/FixedIntervalFillFilter.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/filter/FixedIntervalFillFilter.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.fill.filter;
+package org.apache.iotdb.calc.execution.operator.process.fill.filter;
-import org.apache.iotdb.db.queryengine.execution.operator.process.fill.IFillFilter;
+import org.apache.iotdb.calc.execution.operator.process.fill.IFillFilter;
public class FixedIntervalFillFilter implements IFillFilter {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalMSFillFilter.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/filter/MonthIntervalMSFillFilter.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalMSFillFilter.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/filter/MonthIntervalMSFillFilter.java
index c8e56a8cca9f7..4ff2a56f4a3fd 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalMSFillFilter.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/filter/MonthIntervalMSFillFilter.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.fill.filter;
+package org.apache.iotdb.calc.execution.operator.process.fill.filter;
import java.time.Instant;
import java.time.LocalDateTime;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalNSFillFilter.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/filter/MonthIntervalNSFillFilter.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalNSFillFilter.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/filter/MonthIntervalNSFillFilter.java
index b2c389a1d8753..a19f70365f1c9 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalNSFillFilter.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/filter/MonthIntervalNSFillFilter.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.fill.filter;
+package org.apache.iotdb.calc.execution.operator.process.fill.filter;
import java.time.Instant;
import java.time.LocalDateTime;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalUSFillFilter.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/filter/MonthIntervalUSFillFilter.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalUSFillFilter.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/filter/MonthIntervalUSFillFilter.java
index c99ede2702e35..91674776010fb 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/filter/MonthIntervalUSFillFilter.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/filter/MonthIntervalUSFillFilter.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.fill.filter;
+package org.apache.iotdb.calc.execution.operator.process.fill.filter;
import java.time.Instant;
import java.time.LocalDateTime;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/identity/IdentityFill.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/identity/IdentityFill.java
similarity index 86%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/identity/IdentityFill.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/identity/IdentityFill.java
index 74801480c6448..f504eec6d9c05 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/identity/IdentityFill.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/identity/IdentityFill.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.fill.identity;
+package org.apache.iotdb.calc.execution.operator.process.fill.identity;
-import org.apache.iotdb.db.queryengine.execution.operator.process.fill.IFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.IFill;
import org.apache.tsfile.block.column.Column;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/identity/IdentityLinearFill.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/identity/IdentityLinearFill.java
similarity index 90%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/identity/IdentityLinearFill.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/identity/IdentityLinearFill.java
index 9ccd42ec51e5c..d6650f273ea03 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/identity/IdentityLinearFill.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/identity/IdentityLinearFill.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.fill.identity;
+package org.apache.iotdb.calc.execution.operator.process.fill.identity;
-import org.apache.iotdb.db.queryengine.execution.operator.process.fill.ILinearFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.ILinearFill;
import org.apache.tsfile.block.column.Column;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/linear/LinearFill.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/linear/LinearFill.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/linear/LinearFill.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/linear/LinearFill.java
index 5cd278cc0e7d9..2231b4f029b0c 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/fill/linear/LinearFill.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/fill/linear/LinearFill.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.fill.linear;
+package org.apache.iotdb.calc.execution.operator.process.fill.linear;
-import org.apache.iotdb.db.queryengine.execution.operator.process.fill.ILinearFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.ILinearFill;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.read.common.block.column.RunLengthEncodedColumn;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/PartitionRecognizer.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/function/PartitionRecognizer.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/PartitionRecognizer.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/function/PartitionRecognizer.java
index 21c3be51777ce..deb225f219853 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/PartitionRecognizer.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/function/PartitionRecognizer.java
@@ -17,12 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.function;
+package org.apache.iotdb.calc.execution.operator.process.function;
+import org.apache.iotdb.calc.execution.operator.process.function.partition.PartitionState;
+import org.apache.iotdb.calc.execution.operator.process.function.partition.Slice;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
import org.apache.iotdb.commons.udf.utils.UDFDataTypeTransformer;
-import org.apache.iotdb.db.queryengine.execution.operator.process.function.partition.PartitionState;
-import org.apache.iotdb.db.queryengine.execution.operator.process.function.partition.Slice;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
import org.apache.iotdb.udf.api.type.Type;
import org.apache.tsfile.enums.TSDataType;
@@ -32,8 +32,8 @@
import java.util.List;
import java.util.stream.Collectors;
-import static org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.MergeSortComparator.getComparatorForTable;
-import static org.apache.iotdb.db.queryengine.plan.relational.planner.SortOrder.ASC_NULLS_FIRST;
+import static org.apache.iotdb.calc.execution.operator.process.join.merge.MergeSortComparator.getComparatorForTable;
+import static org.apache.iotdb.commons.queryengine.plan.relational.planner.SortOrder.ASC_NULLS_FIRST;
public class PartitionRecognizer {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/TableFunctionLeafOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/function/TableFunctionLeafOperator.java
similarity index 87%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/TableFunctionLeafOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/function/TableFunctionLeafOperator.java
index 4a8e4d88b8834..0a7f92b249ff8 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/TableFunctionLeafOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/function/TableFunctionLeafOperator.java
@@ -17,11 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.function;
+package org.apache.iotdb.calc.execution.operator.process.function;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.process.ProcessOperator;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
import org.apache.iotdb.commons.exception.IoTDBRuntimeException;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.ProcessOperator;
import org.apache.iotdb.rpc.TSStatusCode;
import org.apache.iotdb.udf.api.relational.table.TableFunctionProcessorProvider;
import org.apache.iotdb.udf.api.relational.table.processor.TableFunctionLeafProcessor;
@@ -38,20 +39,18 @@
import java.util.Arrays;
import java.util.List;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator.TIME_COLUMN_TEMPLATE;
-
// only one input source is supported now
public class TableFunctionLeafOperator implements ProcessOperator {
private static final Logger LOGGER = LoggerFactory.getLogger(TableFunctionLeafOperator.class);
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
private final TsBlockBuilder blockBuilder;
private final TableFunctionLeafProcessor processor;
private volatile boolean init = false;
public TableFunctionLeafOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
TableFunctionProcessorProvider processorProvider,
List outputDataTypes) {
this.operatorContext = operatorContext;
@@ -69,7 +68,7 @@ public ListenableFuture> isBlocked() {
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return this.operatorContext;
}
@@ -94,7 +93,8 @@ private List getOutputColumnBuilders() {
private TsBlock buildTsBlock(List columnBuilders) {
int positionCount = columnBuilders.get(0).getPositionCount();
blockBuilder.declarePositions(positionCount);
- return blockBuilder.build(new RunLengthEncodedColumn(TIME_COLUMN_TEMPLATE, positionCount));
+ return blockBuilder.build(
+ new RunLengthEncodedColumn(CommonOperatorUtils.TIME_COLUMN_TEMPLATE, positionCount));
}
@Override
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/TableFunctionOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/function/TableFunctionOperator.java
similarity index 90%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/TableFunctionOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/function/TableFunctionOperator.java
index c00e05ec17fed..e4f11d7cd49fa 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/TableFunctionOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/function/TableFunctionOperator.java
@@ -17,16 +17,17 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.function;
+package org.apache.iotdb.calc.execution.operator.process.function;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.AggregationMergeSortOperator;
-import org.apache.iotdb.db.queryengine.execution.operator.process.ProcessOperator;
-import org.apache.iotdb.db.queryengine.execution.operator.process.function.partition.PartitionCache;
-import org.apache.iotdb.db.queryengine.execution.operator.process.function.partition.PartitionState;
-import org.apache.iotdb.db.queryengine.execution.operator.process.function.partition.Slice;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.AggregationMergeSortOperator;
+import org.apache.iotdb.calc.execution.operator.process.ProcessOperator;
+import org.apache.iotdb.calc.execution.operator.process.function.partition.PartitionCache;
+import org.apache.iotdb.calc.execution.operator.process.function.partition.PartitionState;
+import org.apache.iotdb.calc.execution.operator.process.function.partition.Slice;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import org.apache.iotdb.udf.api.relational.access.Record;
import org.apache.iotdb.udf.api.relational.table.TableFunctionProcessorProvider;
import org.apache.iotdb.udf.api.relational.table.processor.TableFunctionDataProcessor;
@@ -52,8 +53,6 @@
import java.util.Optional;
import java.util.Queue;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator.TIME_COLUMN_TEMPLATE;
-
// only one input source is supported now
public class TableFunctionOperator implements ProcessOperator {
@@ -63,7 +62,7 @@ public class TableFunctionOperator implements ProcessOperator {
private static final int DEFAULT_MAX_TSBLOCK_SIZE_IN_BYTES =
TSFileDescriptor.getInstance().getConfig().getMaxTsBlockSizeInBytes();
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
private final Operator inputOperator;
private final TableFunctionProcessorProvider processorProvider;
private final PartitionRecognizer partitionRecognizer;
@@ -82,7 +81,7 @@ public class TableFunctionOperator implements ProcessOperator {
private final Queue resultTsBlocks;
public TableFunctionOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
TableFunctionProcessorProvider processorProvider,
Operator inputOperator,
List inputDataTypes,
@@ -110,7 +109,7 @@ public TableFunctionOperator(
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return this.operatorContext;
}
@@ -216,7 +215,8 @@ private List buildTsBlock(
}
properBlockBuilder.declarePositions(positionCount);
TsBlock properBlock =
- properBlockBuilder.build(new RunLengthEncodedColumn(TIME_COLUMN_TEMPLATE, positionCount));
+ properBlockBuilder.build(
+ new RunLengthEncodedColumn(CommonOperatorUtils.TIME_COLUMN_TEMPLATE, positionCount));
List result = new ArrayList<>();
if (needPassThrough) {
// handle pass through column only if needed
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/partition/PartitionCache.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/function/partition/PartitionCache.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/partition/PartitionCache.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/function/partition/PartitionCache.java
index 1797c8fc00e9e..a33113d8f4849 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/partition/PartitionCache.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/function/partition/PartitionCache.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.function.partition;
+package org.apache.iotdb.calc.execution.operator.process.function.partition;
import org.apache.tsfile.block.column.Column;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/partition/PartitionState.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/function/partition/PartitionState.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/partition/PartitionState.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/function/partition/PartitionState.java
index 1c3c6e8686ad8..4f78ec82d387b 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/partition/PartitionState.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/function/partition/PartitionState.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.function.partition;
+package org.apache.iotdb.calc.execution.operator.process.function.partition;
public class PartitionState {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/partition/Slice.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/function/partition/Slice.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/partition/Slice.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/function/partition/Slice.java
index f8f002d5e19d2..aec1722a1baad 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/partition/Slice.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/function/partition/Slice.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.function.partition;
+package org.apache.iotdb.calc.execution.operator.process.function.partition;
-import org.apache.iotdb.db.utils.ObjectTypeUtils;
+import org.apache.iotdb.calc.utils.ObjectTypeUtils;
import org.apache.iotdb.udf.api.relational.access.Record;
import org.apache.iotdb.udf.api.type.Type;
@@ -39,7 +39,7 @@
import java.util.Set;
import java.util.stream.Collectors;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.RecordIterator.OBJECT_ERR_MSG;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.RecordIterator.OBJECT_ERR_MSG;
import static org.apache.iotdb.udf.api.type.Type.OBJECT;
/** Parts of partition. */
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/AbstractGapFillOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/AbstractGapFillOperator.java
similarity index 89%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/AbstractGapFillOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/AbstractGapFillOperator.java
index e9a14aa63a7a5..52fb6b59bace7 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/AbstractGapFillOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/AbstractGapFillOperator.java
@@ -17,13 +17,14 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.gapfill;
+package org.apache.iotdb.calc.execution.operator.process.gapfill;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.ProcessOperator;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.ProcessOperator;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.block.column.Column;
@@ -37,14 +38,13 @@
import java.util.List;
import static com.google.common.base.Preconditions.checkArgument;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator.TIME_COLUMN_TEMPLATE;
abstract class AbstractGapFillOperator implements ProcessOperator {
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(AbstractGapFillOperator.class);
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
private final Operator child;
protected final int outputColumnCount;
private final int timeColumnIndex;
@@ -61,7 +61,7 @@ abstract class AbstractGapFillOperator implements ProcessOperator {
private SortKey lastGroupKey = null;
AbstractGapFillOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator child,
int timeColumnIndex,
long startTime,
@@ -86,7 +86,8 @@ public TsBlock next() throws Exception {
resultBuilder.reset();
fillGaps(lastGroupKey.tsBlock, lastGroupKey.rowIndex, endTime);
return resultBuilder.build(
- new RunLengthEncodedColumn(TIME_COLUMN_TEMPLATE, resultBuilder.getPositionCount()));
+ new RunLengthEncodedColumn(
+ CommonOperatorUtils.TIME_COLUMN_TEMPLATE, resultBuilder.getPositionCount()));
} else {
return null;
}
@@ -130,7 +131,8 @@ public TsBlock next() throws Exception {
}
lastGroupKey = new SortKey(block, size - 1);
return resultBuilder.build(
- new RunLengthEncodedColumn(TIME_COLUMN_TEMPLATE, resultBuilder.getPositionCount()));
+ new RunLengthEncodedColumn(
+ CommonOperatorUtils.TIME_COLUMN_TEMPLATE, resultBuilder.getPositionCount()));
}
private void resetTimeIterator() {
@@ -184,7 +186,7 @@ private void gapFillRow(long time, TsBlock block, int rowIndex) {
abstract void nextTime();
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/AbstractGapFillWGroupOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/AbstractGapFillWGroupOperator.java
similarity index 85%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/AbstractGapFillWGroupOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/AbstractGapFillWGroupOperator.java
index 455202cc166c4..693091e73ae76 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/AbstractGapFillWGroupOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/AbstractGapFillWGroupOperator.java
@@ -17,11 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.gapfill;
+package org.apache.iotdb.calc.execution.operator.process.gapfill;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
import org.apache.tsfile.enums.TSDataType;
@@ -36,7 +36,7 @@ abstract class AbstractGapFillWGroupOperator extends AbstractGapFillOperator {
private final Set groupKeyIndexSet;
AbstractGapFillWGroupOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator child,
int timeColumnIndex,
long startTime,
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/AbstractGapFillWoGroupOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/AbstractGapFillWoGroupOperator.java
similarity index 81%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/AbstractGapFillWoGroupOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/AbstractGapFillWoGroupOperator.java
index 7145af495f44c..0bb942a1e883b 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/AbstractGapFillWoGroupOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/AbstractGapFillWoGroupOperator.java
@@ -17,11 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.gapfill;
+package org.apache.iotdb.calc.execution.operator.process.gapfill;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
import org.apache.tsfile.enums.TSDataType;
@@ -31,7 +31,7 @@
abstract class AbstractGapFillWoGroupOperator extends AbstractGapFillOperator {
AbstractGapFillWoGroupOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator child,
int timeColumnIndex,
long startTime,
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/GapFillWGroupWMoOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/GapFillWGroupWMoOperator.java
similarity index 81%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/GapFillWGroupWMoOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/GapFillWGroupWMoOperator.java
index c3eb335521153..8fee5f74150e2 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/GapFillWGroupWMoOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/GapFillWGroupWMoOperator.java
@@ -17,11 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.gapfill;
+package org.apache.iotdb.calc.execution.operator.process.gapfill;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
import org.apache.tsfile.enums.TSDataType;
@@ -30,7 +30,7 @@
import java.util.List;
import java.util.Set;
-import static org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.DateBinFunctionColumnTransformer.nextDateBin;
+import static org.apache.iotdb.calc.transformation.dag.column.unary.scalar.DateBinFunctionColumnTransformer.nextDateBin;
// with month interval
public class GapFillWGroupWMoOperator extends AbstractGapFillWGroupOperator {
@@ -41,7 +41,7 @@ public class GapFillWGroupWMoOperator extends AbstractGapFillWGroupOperator {
private final ZoneId zoneId;
public GapFillWGroupWMoOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator child,
int timeColumnIndex,
long startTime,
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/GapFillWGroupWoMoOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/GapFillWGroupWoMoOperator.java
similarity index 80%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/GapFillWGroupWoMoOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/GapFillWGroupWoMoOperator.java
index 40cb5fef8cbb4..dc392cc6fc76e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/GapFillWGroupWoMoOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/GapFillWGroupWoMoOperator.java
@@ -17,13 +17,13 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.gapfill;
+package org.apache.iotdb.calc.execution.operator.process.gapfill;
// without month interval
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
import org.apache.tsfile.enums.TSDataType;
@@ -31,7 +31,7 @@
import java.util.List;
import java.util.Set;
-import static org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.DateBinFunctionColumnTransformer.nextDateBin;
+import static org.apache.iotdb.calc.transformation.dag.column.unary.scalar.DateBinFunctionColumnTransformer.nextDateBin;
public class GapFillWGroupWoMoOperator extends AbstractGapFillWGroupOperator {
@@ -40,7 +40,7 @@ public class GapFillWGroupWoMoOperator extends AbstractGapFillWGroupOperator {
private final long nonMonthDuration;
public GapFillWGroupWoMoOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator child,
int timeColumnIndex,
long startTime,
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/GapFillWoGroupWMoOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/GapFillWoGroupWMoOperator.java
similarity index 81%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/GapFillWoGroupWMoOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/GapFillWoGroupWMoOperator.java
index 738e35cd5cf52..a0c0689ab64da 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/GapFillWoGroupWMoOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/GapFillWoGroupWMoOperator.java
@@ -17,17 +17,17 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.gapfill;
+package org.apache.iotdb.calc.execution.operator.process.gapfill;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
import org.apache.tsfile.enums.TSDataType;
import java.time.ZoneId;
import java.util.List;
-import static org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.DateBinFunctionColumnTransformer.nextDateBin;
+import static org.apache.iotdb.calc.transformation.dag.column.unary.scalar.DateBinFunctionColumnTransformer.nextDateBin;
public class GapFillWoGroupWMoOperator extends AbstractGapFillWoGroupOperator {
@@ -37,7 +37,7 @@ public class GapFillWoGroupWMoOperator extends AbstractGapFillWoGroupOperator {
private final ZoneId zoneId;
public GapFillWoGroupWMoOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator child,
int timeColumnIndex,
long startTime,
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/GapFillWoGroupWoMoOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/GapFillWoGroupWoMoOperator.java
similarity index 80%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/GapFillWoGroupWoMoOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/GapFillWoGroupWoMoOperator.java
index d4f8b86abef5d..8b9cac1bdd9d2 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/gapfill/GapFillWoGroupWoMoOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/gapfill/GapFillWoGroupWoMoOperator.java
@@ -17,16 +17,16 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.gapfill;
+package org.apache.iotdb.calc.execution.operator.process.gapfill;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
import org.apache.tsfile.enums.TSDataType;
import java.util.List;
-import static org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.DateBinFunctionColumnTransformer.nextDateBin;
+import static org.apache.iotdb.calc.transformation.dag.column.unary.scalar.DateBinFunctionColumnTransformer.nextDateBin;
public class GapFillWoGroupWoMoOperator extends AbstractGapFillWoGroupOperator {
@@ -35,7 +35,7 @@ public class GapFillWoGroupWoMoOperator extends AbstractGapFillWoGroupOperator {
private final long nonMonthDuration;
public GapFillWoGroupWoMoOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator child,
int timeColumnIndex,
long startTime,
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/SimpleNestedLoopCrossJoinOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/SimpleNestedLoopCrossJoinOperator.java
similarity index 90%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/SimpleNestedLoopCrossJoinOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/SimpleNestedLoopCrossJoinOperator.java
index cb31ea61be63b..8e005fbc97d0b 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/SimpleNestedLoopCrossJoinOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/SimpleNestedLoopCrossJoinOperator.java
@@ -17,13 +17,14 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join;
+package org.apache.iotdb.calc.execution.operator.process.join;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.AbstractOperator;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.plan.planner.memory.MemoryReservationManager;
+import org.apache.iotdb.calc.execution.operator.AbstractOperator;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
+import org.apache.iotdb.calc.plan.planner.memory.MemoryReservationManager;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.block.column.ColumnBuilder;
@@ -37,8 +38,6 @@
import java.util.List;
import java.util.concurrent.TimeUnit;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator.TIME_COLUMN_TEMPLATE;
-
/**
* This Operator is used to implement the simple nested loop join algorithm for Cartesian product.
* It is used to join two tables, one is the probe table and the other is the build table. For now,
@@ -73,7 +72,7 @@ public class SimpleNestedLoopCrossJoinOperator extends AbstractOperator {
private boolean buildFinished = false;
public SimpleNestedLoopCrossJoinOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator probeSource,
Operator buildSource,
int[] leftOutputSymbolIdx,
@@ -86,11 +85,7 @@ public SimpleNestedLoopCrossJoinOperator(
this.rightOutputSymbolIdx = rightOutputSymbolIdx;
this.buildBlocks = new ArrayList<>();
this.resultBuilder = new TsBlockBuilder(dataTypes);
- this.memoryReservationManager =
- operatorContext
- .getDriverContext()
- .getFragmentInstanceContext()
- .getMemoryReservationContext();
+ this.memoryReservationManager = operatorContext.getMemoryReservationContext();
}
@Override
@@ -138,7 +133,8 @@ public TsBlock next() throws Exception {
resultTsBlock =
resultBuilder.build(
- new RunLengthEncodedColumn(TIME_COLUMN_TEMPLATE, resultBuilder.getPositionCount()));
+ new RunLengthEncodedColumn(
+ CommonOperatorUtils.TIME_COLUMN_TEMPLATE, resultBuilder.getPositionCount()));
resultBuilder.reset();
return checkTsBlockSizeAndGetResult();
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/MergeSortComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/MergeSortComparator.java
similarity index 76%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/MergeSortComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/MergeSortComparator.java
index 468e340200af9..a18784e6eecc9 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/MergeSortComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/MergeSortComparator.java
@@ -17,13 +17,10 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join.merge;
+package org.apache.iotdb.calc.execution.operator.process.join.merge;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.SortOrder;
-import org.apache.iotdb.db.queryengine.plan.statement.component.NullOrdering;
-import org.apache.iotdb.db.queryengine.plan.statement.component.Ordering;
-import org.apache.iotdb.db.queryengine.plan.statement.component.SortItem;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.SortOrder;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.external.commons.collections4.comparators.ComparatorChain;
@@ -47,26 +44,6 @@ private MergeSortComparator() {
// util class doesn't need constructor
}
- /** -1 in index is for time column. */
- public static Comparator getComparator(
- List sortItemList, List indexList, List dataTypeList) {
-
- // use code-gen compile this comparator
- List> list = new ArrayList<>(indexList.size());
- for (int i = 0; i < indexList.size(); i++) {
- int index = indexList.get(i);
- if (index == -2) {
- continue;
- }
- TSDataType dataType = dataTypeList.get(i);
- boolean asc = sortItemList.get(i).getOrdering() == Ordering.ASC;
- boolean nullFirst = sortItemList.get(i).getNullOrdering() == NullOrdering.FIRST;
- list.add(genSingleComparator(asc, index, dataType, nullFirst));
- }
-
- return list.size() == 1 ? list.get(0) : new ComparatorChain<>(list);
- }
-
public static Comparator getComparatorForTable(
List sortOrderList, List indexList, List dataTypeList) {
@@ -134,7 +111,7 @@ public static Comparator getComparator(TSDataType dataType, int index,
return comparator;
}
- private static Comparator genSingleComparator(
+ public static Comparator genSingleComparator(
boolean asc, int index, TSDataType dataType, boolean nullFirst) {
if (index == -1) {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/SortKeyComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/SortKeyComparator.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/SortKeyComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/SortKeyComparator.java
index 0959e675d2354..fac0f077eeeba 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/SortKeyComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/SortKeyComparator.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join.merge;
+package org.apache.iotdb.calc.execution.operator.process.join.merge;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
import java.util.Comparator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscBinaryTypeJoinKeyComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscBinaryTypeJoinKeyComparator.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscBinaryTypeJoinKeyComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscBinaryTypeJoinKeyComparator.java
index 9a0f971426177..877e02e445ff2 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscBinaryTypeJoinKeyComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscBinaryTypeJoinKeyComparator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator;
+package org.apache.iotdb.calc.execution.operator.process.join.merge.comparator;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscBooleanTypeJoinKeyComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscBooleanTypeJoinKeyComparator.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscBooleanTypeJoinKeyComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscBooleanTypeJoinKeyComparator.java
index 9203625c69aba..fb5404103d162 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscBooleanTypeJoinKeyComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscBooleanTypeJoinKeyComparator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator;
+package org.apache.iotdb.calc.execution.operator.process.join.merge.comparator;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscDoubleTypeJoinKeyComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscDoubleTypeJoinKeyComparator.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscDoubleTypeJoinKeyComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscDoubleTypeJoinKeyComparator.java
index 0586fa6a53d12..589ddfa0b15bb 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscDoubleTypeJoinKeyComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscDoubleTypeJoinKeyComparator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator;
+package org.apache.iotdb.calc.execution.operator.process.join.merge.comparator;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscFloatTypeJoinKeyComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscFloatTypeJoinKeyComparator.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscFloatTypeJoinKeyComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscFloatTypeJoinKeyComparator.java
index 351cb0599dbd0..75cc370f9d786 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscFloatTypeJoinKeyComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscFloatTypeJoinKeyComparator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator;
+package org.apache.iotdb.calc.execution.operator.process.join.merge.comparator;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscIntTypeJoinKeyComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscIntTypeJoinKeyComparator.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscIntTypeJoinKeyComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscIntTypeJoinKeyComparator.java
index 99b9d23dd946c..e3dd6b5ab6e17 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscIntTypeJoinKeyComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscIntTypeJoinKeyComparator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator;
+package org.apache.iotdb.calc.execution.operator.process.join.merge.comparator;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscLongTypeIgnoreEqualJoinKeyComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscLongTypeIgnoreEqualJoinKeyComparator.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscLongTypeIgnoreEqualJoinKeyComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscLongTypeIgnoreEqualJoinKeyComparator.java
index 8b94dde815bfc..60134c28ae7b9 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscLongTypeIgnoreEqualJoinKeyComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscLongTypeIgnoreEqualJoinKeyComparator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator;
+package org.apache.iotdb.calc.execution.operator.process.join.merge.comparator;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscLongTypeJoinKeyComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscLongTypeJoinKeyComparator.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscLongTypeJoinKeyComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscLongTypeJoinKeyComparator.java
index 793c3f2a1e6ac..23a1c5dde2968 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/AscLongTypeJoinKeyComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/AscLongTypeJoinKeyComparator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator;
+package org.apache.iotdb.calc.execution.operator.process.join.merge.comparator;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescBinaryTypeJoinKeyComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescBinaryTypeJoinKeyComparator.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescBinaryTypeJoinKeyComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescBinaryTypeJoinKeyComparator.java
index b1ee6d5c4af58..0f6654fadd4b2 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescBinaryTypeJoinKeyComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescBinaryTypeJoinKeyComparator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator;
+package org.apache.iotdb.calc.execution.operator.process.join.merge.comparator;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescBooleanTypeJoinKeyComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescBooleanTypeJoinKeyComparator.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescBooleanTypeJoinKeyComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescBooleanTypeJoinKeyComparator.java
index 2402574265c4b..a716e7ac94519 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescBooleanTypeJoinKeyComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescBooleanTypeJoinKeyComparator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator;
+package org.apache.iotdb.calc.execution.operator.process.join.merge.comparator;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescDoubleTypeJoinKeyComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescDoubleTypeJoinKeyComparator.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescDoubleTypeJoinKeyComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescDoubleTypeJoinKeyComparator.java
index 0c20b7d45f8f5..228b42ba46cd3 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescDoubleTypeJoinKeyComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescDoubleTypeJoinKeyComparator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator;
+package org.apache.iotdb.calc.execution.operator.process.join.merge.comparator;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescFloatTypeJoinKeyComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescFloatTypeJoinKeyComparator.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescFloatTypeJoinKeyComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescFloatTypeJoinKeyComparator.java
index de835133f000a..e99dd6f85674f 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescFloatTypeJoinKeyComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescFloatTypeJoinKeyComparator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator;
+package org.apache.iotdb.calc.execution.operator.process.join.merge.comparator;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescIntTypeJoinKeyComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescIntTypeJoinKeyComparator.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescIntTypeJoinKeyComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescIntTypeJoinKeyComparator.java
index f3d5fbadd29dd..96f1cd6f28a64 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescIntTypeJoinKeyComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescIntTypeJoinKeyComparator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator;
+package org.apache.iotdb.calc.execution.operator.process.join.merge.comparator;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescLongTypeIgnoreEqualJoinKeyComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescLongTypeIgnoreEqualJoinKeyComparator.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescLongTypeIgnoreEqualJoinKeyComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescLongTypeIgnoreEqualJoinKeyComparator.java
index 59ea63730d016..b2899fbfc722c 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescLongTypeIgnoreEqualJoinKeyComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescLongTypeIgnoreEqualJoinKeyComparator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator;
+package org.apache.iotdb.calc.execution.operator.process.join.merge.comparator;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescLongTypeJoinKeyComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescLongTypeJoinKeyComparator.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescLongTypeJoinKeyComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescLongTypeJoinKeyComparator.java
index 44849b9a1541f..9ecc482807e07 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/DescLongTypeJoinKeyComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/DescLongTypeJoinKeyComparator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator;
+package org.apache.iotdb.calc.execution.operator.process.join.merge.comparator;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/JoinKeyComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/JoinKeyComparator.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/JoinKeyComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/JoinKeyComparator.java
index 2857f545e1ae2..ab9802050485a 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/JoinKeyComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/JoinKeyComparator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator;
+package org.apache.iotdb.calc.execution.operator.process.join.merge.comparator;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/JoinKeyComparatorFactory.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/JoinKeyComparatorFactory.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/JoinKeyComparatorFactory.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/JoinKeyComparatorFactory.java
index 4ab5f87fb798b..af59f42e92b49 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/JoinKeyComparatorFactory.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/join/merge/comparator/JoinKeyComparatorFactory.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator;
+package org.apache.iotdb.calc.execution.operator.process.join.merge.comparator;
import org.apache.tsfile.read.common.type.Type;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/LogicalIndexNavigation.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/LogicalIndexNavigation.java
similarity index 88%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/LogicalIndexNavigation.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/LogicalIndexNavigation.java
index 4259119dba570..fbf7e709e1f92 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/LogicalIndexNavigation.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/LogicalIndexNavigation.java
@@ -17,15 +17,19 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher.ArrayView;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher.ArrayView;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.IrLabel;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.LogicalIndexPointer;
import java.util.Collections;
+import java.util.Map;
import java.util.Objects;
import java.util.Set;
import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static java.util.Objects.requireNonNull;
public class LogicalIndexNavigation {
@@ -54,6 +58,16 @@ public LogicalIndexNavigation(
this.physicalOffset = physicalOffset;
}
+ public LogicalIndexNavigation(
+ LogicalIndexPointer logicalIndexPointer, Map mapping) {
+ this(
+ logicalIndexPointer.getLabels().stream().map(mapping::get).collect(toImmutableSet()),
+ logicalIndexPointer.isLast(),
+ logicalIndexPointer.isRunning(),
+ logicalIndexPointer.getLogicalOffset(),
+ logicalIndexPointer.getPhysicalOffset());
+ }
+
public Set getLabels() {
return labels;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PatternAggregationTracker.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PatternAggregationTracker.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PatternAggregationTracker.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PatternAggregationTracker.java
index aa0c25b816eaa..7678e38f22a41 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PatternAggregationTracker.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PatternAggregationTracker.java
@@ -17,10 +17,10 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher.ArrayView;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher.IntList;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher.ArrayView;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher.IntList;
import java.util.Set;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PatternAggregator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PatternAggregator.java
similarity index 90%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PatternAggregator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PatternAggregator.java
index 55fc4425041db..d8ac5f5052138 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PatternAggregator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PatternAggregator.java
@@ -17,14 +17,14 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher.ArrayView;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.TableAccumulator;
-import org.apache.iotdb.db.queryengine.plan.relational.function.BoundSignature;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher.ArrayView;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.TableAccumulator;
+import org.apache.iotdb.commons.exception.SemanticException;
+import org.apache.iotdb.commons.queryengine.plan.relational.function.BoundSignature;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
@@ -33,7 +33,7 @@
import java.util.List;
import static java.util.Objects.requireNonNull;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.AbstractTableScanOperator.TIME_COLUMN_TEMPLATE;
+import static org.apache.iotdb.calc.plan.planner.CommonOperatorUtils.TIME_COLUMN_TEMPLATE;
/**
* This class computes an aggregate function result in row pattern recognition context.
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PatternAggregators.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PatternAggregators.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PatternAggregators.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PatternAggregators.java
index d25363f2304ec..7d0667760f9ea 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PatternAggregators.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PatternAggregators.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern;
import java.util.Arrays;
import java.util.List;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PatternPartitionExecutor.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PatternPartitionExecutor.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PatternPartitionExecutor.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PatternPartitionExecutor.java
index 402cc7e831282..8f59701b2fdb5 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PatternPartitionExecutor.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PatternPartitionExecutor.java
@@ -17,19 +17,19 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern;
-
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.PatternVariableRecognizer.PatternVariableComputation;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.expression.PatternExpressionComputation;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher.ArrayView;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher.MatchResult;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher.Matcher;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.utils.ColumnList;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.utils.RowComparator;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.node.RowsPerMatch;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.node.SkipToPosition;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern;
+
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.PatternVariableRecognizer.PatternVariableComputation;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.expression.PatternExpressionComputation;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher.ArrayView;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher.MatchResult;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher.Matcher;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.utils.ColumnList;
+import org.apache.iotdb.calc.execution.operator.process.window.utils.RowComparator;
+import org.apache.iotdb.commons.exception.SemanticException;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.RowsPerMatch;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.SkipToPosition;
import com.google.common.collect.ImmutableList;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PatternVariableRecognizer.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PatternVariableRecognizer.java
similarity index 91%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PatternVariableRecognizer.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PatternVariableRecognizer.java
index 39cd5b163e58a..e9a40006ce272 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PatternVariableRecognizer.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PatternVariableRecognizer.java
@@ -17,12 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.expression.Computation;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.expression.PatternExpressionComputation;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher.ArrayView;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.expression.Computation;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.expression.PatternExpressionComputation;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher.ArrayView;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
import java.util.List;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PhysicalAggregationPointer.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PhysicalAggregationPointer.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PhysicalAggregationPointer.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PhysicalAggregationPointer.java
index ed1ada2ac036e..5bb36aa702855 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PhysicalAggregationPointer.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PhysicalAggregationPointer.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern;
public class PhysicalAggregationPointer implements PhysicalValueAccessor {
private final int index;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PhysicalValueAccessor.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PhysicalValueAccessor.java
similarity index 91%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PhysicalValueAccessor.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PhysicalValueAccessor.java
index 81dd0ad095f6a..cf9abfb210de0 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PhysicalValueAccessor.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PhysicalValueAccessor.java
@@ -17,6 +17,6 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern;
public interface PhysicalValueAccessor {}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PhysicalValuePointer.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PhysicalValuePointer.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PhysicalValuePointer.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PhysicalValuePointer.java
index 414705dbbf599..d10039d49a3f1 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/PhysicalValuePointer.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/PhysicalValuePointer.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern;
import org.apache.tsfile.read.common.type.Type;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/ArithmeticOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/ArithmeticOperator.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/ArithmeticOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/ArithmeticOperator.java
index 59f0cbdc42a8f..de2196356285a 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/ArithmeticOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/ArithmeticOperator.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.expression;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.expression;
-import org.apache.iotdb.db.exception.sql.SemanticException;
+import org.apache.iotdb.commons.exception.SemanticException;
public enum ArithmeticOperator implements BinaryOperator {
ADD {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/BinaryComputation.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/BinaryComputation.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/BinaryComputation.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/BinaryComputation.java
index 32a14cb7ce4c6..8732c07a9c42e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/BinaryComputation.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/BinaryComputation.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.expression;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.expression;
import java.util.List;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/BinaryOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/BinaryOperator.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/BinaryOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/BinaryOperator.java
index f913b64968502..d63c0d0ef4f48 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/BinaryOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/BinaryOperator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.expression;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.expression;
public interface BinaryOperator {
/**
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/CastComputation.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/CastComputation.java
similarity index 91%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/CastComputation.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/CastComputation.java
index 9f4ad2f13af8b..1b50f37bc76e8 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/CastComputation.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/CastComputation.java
@@ -17,10 +17,10 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.expression;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.expression;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.DataType;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.GenericDataType;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.DataType;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.GenericDataType;
import java.util.List;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/ComparisonOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/ComparisonOperator.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/ComparisonOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/ComparisonOperator.java
index 96bd1d991b057..0a3c0c1105bbb 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/ComparisonOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/ComparisonOperator.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.expression;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.expression;
-import org.apache.iotdb.db.exception.sql.SemanticException;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.utils.Binary;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/Computation.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/Computation.java
similarity index 85%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/Computation.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/Computation.java
index 33661fd206a57..187002f7e201c 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/Computation.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/Computation.java
@@ -17,25 +17,25 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.expression;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.expression;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.rowpattern.ExpressionAndValuePointers;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.rowpattern.ExpressionAndValuePointers.Assignment;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ArithmeticBinaryExpression;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.BinaryLiteral;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.BooleanLiteral;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Cast;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ComparisonExpression;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.DataType;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.DoubleLiteral;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Expression;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.FloatLiteral;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.GenericLiteral;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.LogicalExpression;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.LongLiteral;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.StringLiteral;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SymbolReference;
+import org.apache.iotdb.commons.exception.SemanticException;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.ExpressionAndValuePointers;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.ExpressionAndValuePointers.Assignment;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.ArithmeticBinaryExpression;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.BinaryLiteral;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.BooleanLiteral;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.Cast;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.ComparisonExpression;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.DataType;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.DoubleLiteral;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.Expression;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.FloatLiteral;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.GenericLiteral;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.LogicalExpression;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.LongLiteral;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.StringLiteral;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.SymbolReference;
import java.util.ArrayList;
import java.util.HashMap;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/ConstantComputation.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/ConstantComputation.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/ConstantComputation.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/ConstantComputation.java
index 6412917ff0a4e..068a47074858a 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/ConstantComputation.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/ConstantComputation.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.expression;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.expression;
import java.util.List;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/LogicalOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/LogicalOperator.java
similarity index 91%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/LogicalOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/LogicalOperator.java
index c426cbd16939c..1f7fcc99bb1b3 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/LogicalOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/LogicalOperator.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.expression;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.expression;
-import org.apache.iotdb.db.exception.sql.SemanticException;
+import org.apache.iotdb.commons.exception.SemanticException;
import java.util.List;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/NaryComputation.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/NaryComputation.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/NaryComputation.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/NaryComputation.java
index 291f95d046be4..b077ccd1b3593 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/NaryComputation.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/NaryComputation.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.expression;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.expression;
import java.util.ArrayList;
import java.util.List;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/NaryOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/NaryOperator.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/NaryOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/NaryOperator.java
index 1d5d469a6b466..6bbc102aa986d 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/NaryOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/NaryOperator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.expression;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.expression;
import java.util.List;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/PatternExpressionComputation.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/PatternExpressionComputation.java
similarity index 86%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/PatternExpressionComputation.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/PatternExpressionComputation.java
index cb8cbdccbb695..d27d028b361e6 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/PatternExpressionComputation.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/PatternExpressionComputation.java
@@ -17,15 +17,15 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.expression;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.expression;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.PatternAggregator;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.PhysicalAggregationPointer;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.PhysicalValueAccessor;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.PhysicalValuePointer;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher.ArrayView;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.PatternAggregator;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.PhysicalAggregationPointer;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.PhysicalValueAccessor;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.PhysicalValuePointer;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher.ArrayView;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.read.common.type.AbstractIntType;
@@ -41,8 +41,8 @@
import java.util.ArrayList;
import java.util.List;
-import static org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.PhysicalValuePointer.CLASSIFIER;
-import static org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.PhysicalValuePointer.MATCH_NUMBER;
+import static org.apache.iotdb.calc.execution.operator.process.rowpattern.PhysicalValuePointer.CLASSIFIER;
+import static org.apache.iotdb.calc.execution.operator.process.rowpattern.PhysicalValuePointer.MATCH_NUMBER;
import static org.apache.tsfile.enums.TSDataType.STRING;
public class PatternExpressionComputation {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/ReferenceComputation.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/ReferenceComputation.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/ReferenceComputation.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/ReferenceComputation.java
index 8d8b7fd6367fa..b659103f5cdf5 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/expression/ReferenceComputation.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/expression/ReferenceComputation.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.expression;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.expression;
import java.util.List;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/ArrayView.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/ArrayView.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/ArrayView.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/ArrayView.java
index 63197a26ccf65..718f1aafe48a4 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/ArrayView.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/ArrayView.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher;
import com.google.common.annotations.VisibleForTesting;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Done.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Done.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Done.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Done.java
index 08e26baca8a89..5599f223fc429 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Done.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Done.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher;
class Done implements Instruction {
@Override
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Instruction.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Instruction.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Instruction.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Instruction.java
index 68400950271c0..6f24533011145 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Instruction.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Instruction.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher;
interface Instruction {
enum Type {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/IntList.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/IntList.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/IntList.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/IntList.java
index c5fd5dd2620d8..423f0281b81aa 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/IntList.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/IntList.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/IntMultimap.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/IntMultimap.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/IntMultimap.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/IntMultimap.java
index 3baf0ef782e10..df701f9e9d425 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/IntMultimap.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/IntMultimap.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/IntStack.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/IntStack.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/IntStack.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/IntStack.java
index 47fbc1ca5d4a8..d558e8af7f8ff 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/IntStack.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/IntStack.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/IrRowPatternToProgramRewriter.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/IrRowPatternToProgramRewriter.java
similarity index 88%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/IrRowPatternToProgramRewriter.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/IrRowPatternToProgramRewriter.java
index 37de296d54c56..fccf755bcaba5 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/IrRowPatternToProgramRewriter.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/IrRowPatternToProgramRewriter.java
@@ -17,19 +17,19 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher;
-
-import org.apache.iotdb.db.queryengine.plan.relational.planner.rowpattern.IrAlternation;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.rowpattern.IrAnchor;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.rowpattern.IrConcatenation;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.rowpattern.IrEmpty;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.rowpattern.IrExclusion;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.rowpattern.IrLabel;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.rowpattern.IrPermutation;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.rowpattern.IrQuantified;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.rowpattern.IrQuantifier;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.rowpattern.IrRowPattern;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.rowpattern.IrRowPatternVisitor;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher;
+
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.IrAlternation;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.IrAnchor;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.IrConcatenation;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.IrEmpty;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.IrExclusion;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.IrLabel;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.IrPermutation;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.IrQuantified;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.IrQuantifier;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.IrRowPattern;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.IrRowPatternVisitor;
import java.util.ArrayList;
import java.util.List;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Jump.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Jump.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Jump.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Jump.java
index c75698c97f82b..2d47f70221ab7 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Jump.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Jump.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher;
import java.util.Objects;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/MatchEnd.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/MatchEnd.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/MatchEnd.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/MatchEnd.java
index 7d14586186ba0..54e1686e4d267 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/MatchEnd.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/MatchEnd.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher;
class MatchEnd implements Instruction {
@Override
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/MatchLabel.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/MatchLabel.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/MatchLabel.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/MatchLabel.java
index d839508ea30ee..d4596fff32107 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/MatchLabel.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/MatchLabel.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher;
import java.util.Objects;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/MatchResult.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/MatchResult.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/MatchResult.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/MatchResult.java
index fd79e55589db9..0e3511c0a526f 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/MatchResult.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/MatchResult.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher;
import static java.util.Objects.requireNonNull;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/MatchStart.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/MatchStart.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/MatchStart.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/MatchStart.java
index f8dd5e5597a27..764cb9ad8e16f 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/MatchStart.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/MatchStart.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher;
class MatchStart implements Instruction {
@Override
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Matcher.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Matcher.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Matcher.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Matcher.java
index ffb5f7e6fce5e..0d3f6889dbc42 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Matcher.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Matcher.java
@@ -17,17 +17,17 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.PatternAggregator;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.PatternAggregators;
-import org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.PatternVariableRecognizer;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.PatternAggregator;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.PatternAggregators;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.PatternVariableRecognizer;
import org.apache.tsfile.utils.RamUsageEstimator;
import java.util.List;
-import static org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher.MatchResult.NO_MATCH;
+import static org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher.MatchResult.NO_MATCH;
public class Matcher {
private final Program program;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/PatternCaptures.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/PatternCaptures.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/PatternCaptures.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/PatternCaptures.java
index 640ae54e98c23..26bf682d11cb2 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/PatternCaptures.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/PatternCaptures.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher;
-import org.apache.iotdb.db.queryengine.plan.relational.utils.matching.Captures;
+import org.apache.iotdb.calc.plan.relational.utils.matching.Captures;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Program.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Program.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Program.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Program.java
index d679cad42dcb8..f43e5f876d565 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Program.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Program.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher;
import com.google.common.collect.ImmutableList;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Save.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Save.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Save.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Save.java
index fceac14288256..f20e300d3e704 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Save.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Save.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher;
class Save implements Instruction {
@Override
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Split.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Split.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Split.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Split.java
index 5376ad44ba261..bb9d64fb6e807 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/rowpattern/matcher/Split.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/rowpattern/matcher/Split.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.rowpattern.matcher;
+package org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher;
import java.util.Objects;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/RowNumberOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/RowNumberOperator.java
similarity index 86%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/RowNumberOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/RowNumberOperator.java
index 7861a8dbbee20..e676c3a7da419 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/RowNumberOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/RowNumberOperator.java
@@ -16,15 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window;
+package org.apache.iotdb.calc.execution.operator.process.window;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.ProcessOperator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.UpdateMemory;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.hash.GroupByHash;
-import org.apache.iotdb.db.queryengine.plan.relational.type.InternalTypeManager;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.ProcessOperator;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
+import org.apache.iotdb.commons.queryengine.execution.operator.source.relational.aggregation.grouped.UpdateMemory;
+import org.apache.iotdb.commons.queryengine.execution.operator.source.relational.aggregation.grouped.hash.GroupByHash;
+import org.apache.iotdb.commons.queryengine.plan.relational.type.InternalTypeManager;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture;
@@ -44,14 +44,14 @@
import java.util.Map;
import java.util.Optional;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.AbstractTableScanOperator.TIME_COLUMN_TEMPLATE;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.hash.GroupByHash.createGroupByHash;
+import static org.apache.iotdb.calc.plan.planner.CommonOperatorUtils.TIME_COLUMN_TEMPLATE;
+import static org.apache.iotdb.commons.queryengine.execution.operator.source.relational.aggregation.grouped.hash.GroupByHash.createGroupByHash;
public class RowNumberOperator implements ProcessOperator {
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(RowNumberOperator.class);
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
private final Operator inputOperator;
private final List outputChannels;
private final List partitionChannels;
@@ -62,7 +62,7 @@ public class RowNumberOperator implements ProcessOperator {
private final Map partitionRowCounts;
public RowNumberOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator inputOperator,
List inputDataTypes,
List outputChannels,
@@ -103,7 +103,7 @@ public RowNumberOperator(
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/TableWindowOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/TableWindowOperator.java
similarity index 83%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/TableWindowOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/TableWindowOperator.java
index 32e1a44ce45db..8dde114569641 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/TableWindowOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/TableWindowOperator.java
@@ -17,21 +17,22 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window;
-
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.ProcessOperator;
-import org.apache.iotdb.db.queryengine.execution.operator.process.function.PartitionRecognizer;
-import org.apache.iotdb.db.queryengine.execution.operator.process.function.partition.PartitionCache;
-import org.apache.iotdb.db.queryengine.execution.operator.process.function.partition.PartitionState;
-import org.apache.iotdb.db.queryengine.execution.operator.process.function.partition.Slice;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.WindowFunction;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.PartitionExecutor;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.frame.FrameInfo;
-import org.apache.iotdb.db.queryengine.plan.planner.memory.MemoryReservationManager;
+package org.apache.iotdb.calc.execution.operator.process.window;
+
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.ProcessOperator;
+import org.apache.iotdb.calc.execution.operator.process.function.PartitionRecognizer;
+import org.apache.iotdb.calc.execution.operator.process.function.partition.PartitionCache;
+import org.apache.iotdb.calc.execution.operator.process.function.partition.PartitionState;
+import org.apache.iotdb.calc.execution.operator.process.function.partition.Slice;
+import org.apache.iotdb.calc.execution.operator.process.window.function.WindowFunction;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.PartitionExecutor;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.frame.FrameInfo;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
+import org.apache.iotdb.calc.plan.planner.memory.MemoryReservationManager;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture;
@@ -48,15 +49,14 @@
import java.util.List;
import java.util.concurrent.TimeUnit;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator.TIME_COLUMN_TEMPLATE;
-import static org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanGraphPrinter.MAX_RESERVED_MEMORY;
+import static org.apache.iotdb.calc.plan.planner.CommonOperatorUtils.MAX_RESERVED_MEMORY;
public class TableWindowOperator implements ProcessOperator {
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(TableWindowOperator.class);
// Common fields
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
private final Operator inputOperator;
private final List inputDataTypes;
private final List outputChannels;
@@ -84,7 +84,7 @@ public class TableWindowOperator implements ProcessOperator {
private boolean noMoreDataSignaled;
public TableWindowOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator inputOperator,
List inputDataTypes,
List outputDataTypes,
@@ -119,15 +119,11 @@ public TableWindowOperator(
this.totalMemorySize = 0;
this.maxUsedMemory = 0;
this.noMoreDataSignaled = false;
- this.memoryReservationManager =
- operatorContext
- .getDriverContext()
- .getFragmentInstanceContext()
- .getMemoryReservationContext();
+ this.memoryReservationManager = operatorContext.getMemoryReservationContext();
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
@@ -245,7 +241,8 @@ private TsBlock transform(long startTime) {
private TsBlock getTsBlockFromTsBlockBuilder() {
TsBlock result =
tsBlockBuilder.build(
- new RunLengthEncodedColumn(TIME_COLUMN_TEMPLATE, tsBlockBuilder.getPositionCount()));
+ new RunLengthEncodedColumn(
+ CommonOperatorUtils.TIME_COLUMN_TEMPLATE, tsBlockBuilder.getPositionCount()));
tsBlockBuilder.reset();
return result;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/TopKRankingOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/TopKRankingOperator.java
similarity index 85%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/TopKRankingOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/TopKRankingOperator.java
index b94c546ac5497..e42a935d4e0a8 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/TopKRankingOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/TopKRankingOperator.java
@@ -17,22 +17,22 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window;
-
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.GroupedTopNBuilder;
-import org.apache.iotdb.db.queryengine.execution.operator.GroupedTopNRowNumberBuilder;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.SimpleTsBlockWithPositionComparator;
-import org.apache.iotdb.db.queryengine.execution.operator.TsBlockWithPositionComparator;
-import org.apache.iotdb.db.queryengine.execution.operator.process.ProcessOperator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.UpdateMemory;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.hash.GroupByHash;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.hash.NoChannelGroupByHash;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.SortOrder;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.node.TopKRankingNode;
-import org.apache.iotdb.db.queryengine.plan.relational.type.InternalTypeManager;
+package org.apache.iotdb.calc.execution.operator.process.window;
+
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.GroupedTopNBuilder;
+import org.apache.iotdb.calc.execution.operator.GroupedTopNRowNumberBuilder;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.SimpleTsBlockWithPositionComparator;
+import org.apache.iotdb.calc.execution.operator.TsBlockWithPositionComparator;
+import org.apache.iotdb.calc.execution.operator.process.ProcessOperator;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
+import org.apache.iotdb.commons.queryengine.execution.operator.source.relational.aggregation.grouped.UpdateMemory;
+import org.apache.iotdb.commons.queryengine.execution.operator.source.relational.aggregation.grouped.hash.GroupByHash;
+import org.apache.iotdb.commons.queryengine.execution.operator.source.relational.aggregation.grouped.hash.NoChannelGroupByHash;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.SortOrder;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.TopKRankingNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.type.InternalTypeManager;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
@@ -51,7 +51,7 @@ public class TopKRankingOperator implements ProcessOperator {
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(TopKRankingOperator.class);
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
private final Operator inputOperator;
private final TopKRankingNode.RankingType rankingType;
private final List inputTypes;
@@ -78,7 +78,7 @@ public class TopKRankingOperator implements ProcessOperator {
private java.util.Iterator outputIterator;
public TopKRankingOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator inputOperator,
TopKRankingNode.RankingType rankingType,
List inputTypes,
@@ -169,7 +169,7 @@ private Supplier getGroupedTopNBuilderSupplier() {
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/WindowFunction.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/WindowFunction.java
similarity index 87%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/WindowFunction.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/WindowFunction.java
index acaf72da85654..6ce00df0d7edb 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/WindowFunction.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/WindowFunction.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.function;
+package org.apache.iotdb.calc.execution.operator.process.window.function;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/WindowFunctionFactory.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/WindowFunctionFactory.java
similarity index 62%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/WindowFunctionFactory.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/WindowFunctionFactory.java
index 04c8a774deb27..5a88fbf786d18 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/WindowFunctionFactory.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/WindowFunctionFactory.java
@@ -17,19 +17,19 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.function;
+package org.apache.iotdb.calc.execution.operator.process.window.function;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.rank.CumeDistFunction;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.rank.DenseRankFunction;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.rank.NTileFunction;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.rank.PercentRankFunction;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.rank.RankFunction;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.rank.RowNumberFunction;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.value.FirstValueFunction;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.value.LagFunction;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.value.LastValueFunction;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.value.LeadFunction;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.value.NthValueFunction;
+import org.apache.iotdb.calc.execution.operator.process.window.function.rank.CumeDistFunction;
+import org.apache.iotdb.calc.execution.operator.process.window.function.rank.DenseRankFunction;
+import org.apache.iotdb.calc.execution.operator.process.window.function.rank.NTileFunction;
+import org.apache.iotdb.calc.execution.operator.process.window.function.rank.PercentRankFunction;
+import org.apache.iotdb.calc.execution.operator.process.window.function.rank.RankFunction;
+import org.apache.iotdb.calc.execution.operator.process.window.function.rank.RowNumberFunction;
+import org.apache.iotdb.calc.execution.operator.process.window.function.value.FirstValueFunction;
+import org.apache.iotdb.calc.execution.operator.process.window.function.value.LagFunction;
+import org.apache.iotdb.calc.execution.operator.process.window.function.value.LastValueFunction;
+import org.apache.iotdb.calc.execution.operator.process.window.function.value.LeadFunction;
+import org.apache.iotdb.calc.execution.operator.process.window.function.value.NthValueFunction;
import java.util.List;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/aggregate/AggregationWindowFunction.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/aggregate/AggregationWindowFunction.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/aggregate/AggregationWindowFunction.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/aggregate/AggregationWindowFunction.java
index b8f5a95f3fa3b..2b1ec10343901 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/aggregate/AggregationWindowFunction.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/aggregate/AggregationWindowFunction.java
@@ -17,10 +17,10 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.function.aggregate;
+package org.apache.iotdb.calc.execution.operator.process.window.function.aggregate;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.WindowFunction;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.function.WindowFunction;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/aggregate/WindowAggregator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/aggregate/WindowAggregator.java
similarity index 83%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/aggregate/WindowAggregator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/aggregate/WindowAggregator.java
index 5d540db574425..874d365d61a7a 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/aggregate/WindowAggregator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/aggregate/WindowAggregator.java
@@ -17,11 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.function.aggregate;
+package org.apache.iotdb.calc.execution.operator.process.window.function.aggregate;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.TableAccumulator;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.TableAccumulator;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
import com.google.common.primitives.Ints;
import org.apache.tsfile.block.column.Column;
@@ -33,7 +34,6 @@
import java.util.List;
import static java.util.Objects.requireNonNull;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator.TIME_COLUMN_TEMPLATE;
public class WindowAggregator {
private final TableAccumulator accumulator;
@@ -67,7 +67,10 @@ public void addInput(Column[] columns) {
// Process count(*)
int count = columns[0].getPositionCount();
if (arguments.length == 0) {
- arguments = new Column[] {new RunLengthEncodedColumn(TIME_COLUMN_TEMPLATE, count)};
+ arguments =
+ new Column[] {
+ new RunLengthEncodedColumn(CommonOperatorUtils.TIME_COLUMN_TEMPLATE, count)
+ };
}
AggregationMask mask = AggregationMask.createSelectAll(count);
@@ -90,7 +93,10 @@ private void removeInput(Column[] columns) {
// Process count(*)
int count = columns[0].getPositionCount();
if (arguments.length == 0) {
- arguments = new Column[] {new RunLengthEncodedColumn(TIME_COLUMN_TEMPLATE, count)};
+ arguments =
+ new Column[] {
+ new RunLengthEncodedColumn(CommonOperatorUtils.TIME_COLUMN_TEMPLATE, count)
+ };
}
accumulator.removeInput(arguments);
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/CumeDistFunction.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/CumeDistFunction.java
similarity index 88%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/CumeDistFunction.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/CumeDistFunction.java
index e4745bd0ad54b..7e8c9535f0c41 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/CumeDistFunction.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/CumeDistFunction.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.function.rank;
+package org.apache.iotdb.calc.execution.operator.process.window.function.rank;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/DenseRankFunction.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/DenseRankFunction.java
similarity index 87%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/DenseRankFunction.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/DenseRankFunction.java
index ac16fcf66f088..f116847007da3 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/DenseRankFunction.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/DenseRankFunction.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.function.rank;
+package org.apache.iotdb.calc.execution.operator.process.window.function.rank;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/NTileFunction.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/NTileFunction.java
similarity index 91%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/NTileFunction.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/NTileFunction.java
index c218215f19832..c89b43124d67a 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/NTileFunction.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/NTileFunction.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.function.rank;
+package org.apache.iotdb.calc.execution.operator.process.window.function.rank;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/PercentRankFunction.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/PercentRankFunction.java
similarity index 89%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/PercentRankFunction.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/PercentRankFunction.java
index 35741eb4078b4..ea29c2a95ccfd 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/PercentRankFunction.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/PercentRankFunction.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.function.rank;
+package org.apache.iotdb.calc.execution.operator.process.window.function.rank;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/RankFunction.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/RankFunction.java
similarity index 88%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/RankFunction.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/RankFunction.java
index c6fbf710e725d..2612312724289 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/RankFunction.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/RankFunction.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.function.rank;
+package org.apache.iotdb.calc.execution.operator.process.window.function.rank;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/RankWindowFunction.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/RankWindowFunction.java
similarity index 86%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/RankWindowFunction.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/RankWindowFunction.java
index b2c672afbea65..ad6b64f6e9e89 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/RankWindowFunction.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/RankWindowFunction.java
@@ -17,10 +17,10 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.function.rank;
+package org.apache.iotdb.calc.execution.operator.process.window.function.rank;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.WindowFunction;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.function.WindowFunction;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/RowNumberFunction.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/RowNumberFunction.java
similarity index 86%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/RowNumberFunction.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/RowNumberFunction.java
index 67a790557bcb8..b9343c702ee86 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/rank/RowNumberFunction.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/rank/RowNumberFunction.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.function.rank;
+package org.apache.iotdb.calc.execution.operator.process.window.function.rank;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/FirstValueFunction.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/value/FirstValueFunction.java
similarity index 90%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/FirstValueFunction.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/value/FirstValueFunction.java
index 465ec2920fc28..efd9f0309b5b3 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/FirstValueFunction.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/value/FirstValueFunction.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.function.value;
+package org.apache.iotdb.calc.execution.operator.process.window.function.value;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/LagFunction.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/value/LagFunction.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/LagFunction.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/value/LagFunction.java
index 91e39753344d9..9ac4708c33c3e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/LagFunction.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/value/LagFunction.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.function.value;
+package org.apache.iotdb.calc.execution.operator.process.window.function.value;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
import org.apache.tsfile.block.column.ColumnBuilder;
import org.apache.tsfile.enums.TSDataType;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/LastValueFunction.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/value/LastValueFunction.java
similarity index 90%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/LastValueFunction.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/value/LastValueFunction.java
index 1c929d035be34..d9c918dda32b5 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/LastValueFunction.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/value/LastValueFunction.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.function.value;
+package org.apache.iotdb.calc.execution.operator.process.window.function.value;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/LeadFunction.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/value/LeadFunction.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/LeadFunction.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/value/LeadFunction.java
index c51eac1563596..37b71595f0f65 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/LeadFunction.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/value/LeadFunction.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.function.value;
+package org.apache.iotdb.calc.execution.operator.process.window.function.value;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
import org.apache.tsfile.block.column.ColumnBuilder;
import org.apache.tsfile.enums.TSDataType;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/NthValueFunction.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/value/NthValueFunction.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/NthValueFunction.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/value/NthValueFunction.java
index 83c245119ff01..f6b8ced1921c6 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/NthValueFunction.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/value/NthValueFunction.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.function.value;
+package org.apache.iotdb.calc.execution.operator.process.window.function.value;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/ValueWindowFunction.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/value/ValueWindowFunction.java
similarity index 84%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/ValueWindowFunction.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/value/ValueWindowFunction.java
index 45e5b9def92b0..daf30551e49c9 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/ValueWindowFunction.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/function/value/ValueWindowFunction.java
@@ -17,10 +17,10 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.function.value;
+package org.apache.iotdb.calc.execution.operator.process.window.function.value;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.WindowFunction;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.function.WindowFunction;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/Partition.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/Partition.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/Partition.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/Partition.java
index ac23bbc9fef34..eebbee937d05e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/Partition.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/Partition.java
@@ -17,10 +17,10 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.partition;
+package org.apache.iotdb.calc.execution.operator.process.window.partition;
-import org.apache.iotdb.db.queryengine.execution.operator.process.function.partition.Slice;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.utils.ColumnList;
+import org.apache.iotdb.calc.execution.operator.process.function.partition.Slice;
+import org.apache.iotdb.calc.execution.operator.process.window.utils.ColumnList;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/PartitionExecutor.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/PartitionExecutor.java
similarity index 87%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/PartitionExecutor.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/PartitionExecutor.java
index d5a68ea579672..bdf55cae5b18d 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/PartitionExecutor.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/PartitionExecutor.java
@@ -17,17 +17,17 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.partition;
-
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.function.WindowFunction;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.frame.Frame;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.frame.FrameInfo;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.frame.GroupsFrame;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.frame.RangeFrame;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.frame.RowsFrame;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.utils.ColumnList;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.utils.Range;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.utils.RowComparator;
+package org.apache.iotdb.calc.execution.operator.process.window.partition;
+
+import org.apache.iotdb.calc.execution.operator.process.window.function.WindowFunction;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.frame.Frame;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.frame.FrameInfo;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.frame.GroupsFrame;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.frame.RangeFrame;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.frame.RowsFrame;
+import org.apache.iotdb.calc.execution.operator.process.window.utils.ColumnList;
+import org.apache.iotdb.calc.execution.operator.process.window.utils.Range;
+import org.apache.iotdb.calc.execution.operator.process.window.utils.RowComparator;
import com.google.common.collect.ImmutableList;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/frame/Frame.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/frame/Frame.java
similarity index 84%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/frame/Frame.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/frame/Frame.java
index b697420443c58..b207f51399258 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/frame/Frame.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/frame/Frame.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.frame;
+package org.apache.iotdb.calc.execution.operator.process.window.partition.frame;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.utils.Range;
+import org.apache.iotdb.calc.execution.operator.process.window.utils.Range;
public interface Frame {
Range getRange(int currentPosition, int currentGroup, int peerGroupStart, int peerGroupEnd);
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/frame/FrameInfo.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/frame/FrameInfo.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/frame/FrameInfo.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/frame/FrameInfo.java
index 78cb7d2b9e4db..5b9965b141afc 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/frame/FrameInfo.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/frame/FrameInfo.java
@@ -17,11 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.frame;
+package org.apache.iotdb.calc.execution.operator.process.window.partition.frame;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.SortOrder;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.FrameBound;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.WindowFrame;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.SortOrder;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.FrameBound;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.WindowFrame;
import java.util.Optional;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/frame/GroupsFrame.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/frame/GroupsFrame.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/frame/GroupsFrame.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/frame/GroupsFrame.java
index 3e9b111301da8..c89de0d0403e5 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/frame/GroupsFrame.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/frame/GroupsFrame.java
@@ -17,13 +17,13 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.frame;
+package org.apache.iotdb.calc.execution.operator.process.window.partition.frame;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.utils.ColumnList;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.utils.Range;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.utils.RowComparator;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.utils.ColumnList;
+import org.apache.iotdb.calc.execution.operator.process.window.utils.Range;
+import org.apache.iotdb.calc.execution.operator.process.window.utils.RowComparator;
+import org.apache.iotdb.commons.exception.SemanticException;
import java.util.List;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/frame/RangeFrame.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/frame/RangeFrame.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/frame/RangeFrame.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/frame/RangeFrame.java
index 64981fb62323b..60fa6619bd818 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/frame/RangeFrame.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/frame/RangeFrame.java
@@ -17,13 +17,13 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.frame;
+package org.apache.iotdb.calc.execution.operator.process.window.partition.frame;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.utils.ColumnList;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.utils.Range;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.utils.RowComparator;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.utils.ColumnList;
+import org.apache.iotdb.calc.execution.operator.process.window.utils.Range;
+import org.apache.iotdb.calc.execution.operator.process.window.utils.RowComparator;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.write.UnSupportedDataTypeException;
@@ -31,9 +31,9 @@
import java.util.List;
import static com.google.common.base.Preconditions.checkArgument;
-import static org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.frame.FrameInfo.FrameBoundType.CURRENT_ROW;
-import static org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.frame.FrameInfo.FrameBoundType.UNBOUNDED_FOLLOWING;
-import static org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.frame.FrameInfo.FrameBoundType.UNBOUNDED_PRECEDING;
+import static org.apache.iotdb.calc.execution.operator.process.window.partition.frame.FrameInfo.FrameBoundType.CURRENT_ROW;
+import static org.apache.iotdb.calc.execution.operator.process.window.partition.frame.FrameInfo.FrameBoundType.UNBOUNDED_FOLLOWING;
+import static org.apache.iotdb.calc.execution.operator.process.window.partition.frame.FrameInfo.FrameBoundType.UNBOUNDED_PRECEDING;
public class RangeFrame implements Frame {
private final Partition partition;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/frame/RowsFrame.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/frame/RowsFrame.java
similarity index 91%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/frame/RowsFrame.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/frame/RowsFrame.java
index 51f386e4f6577..6b87a5de9db07 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/partition/frame/RowsFrame.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/partition/frame/RowsFrame.java
@@ -17,11 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.frame;
+package org.apache.iotdb.calc.execution.operator.process.window.partition.frame;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.partition.Partition;
-import org.apache.iotdb.db.queryengine.execution.operator.process.window.utils.Range;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.Partition;
+import org.apache.iotdb.calc.execution.operator.process.window.utils.Range;
+import org.apache.iotdb.commons.exception.SemanticException;
import static com.google.common.base.Preconditions.checkArgument;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/utils/ColumnList.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/utils/ColumnList.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/utils/ColumnList.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/utils/ColumnList.java
index 97152b715d804..8a6da136464cd 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/utils/ColumnList.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/utils/ColumnList.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.utils;
+package org.apache.iotdb.calc.execution.operator.process.window.utils;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnEncoding;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/utils/Range.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/utils/Range.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/utils/Range.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/utils/Range.java
index 9994742bbfee4..e7d462d109916 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/utils/Range.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/utils/Range.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.utils;
+package org.apache.iotdb.calc.execution.operator.process.window.utils;
public class Range {
private final int start;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/utils/RowComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/utils/RowComparator.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/utils/RowComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/utils/RowComparator.java
index 73ff0fe60e64c..6f01fb96d94ec 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/utils/RowComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/process/window/utils/RowComparator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.process.window.utils;
+package org.apache.iotdb.calc.execution.operator.process.window.utils;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.enums.TSDataType;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/AbstractAsofMergeSortJoinOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/AbstractAsofMergeSortJoinOperator.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/AbstractAsofMergeSortJoinOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/AbstractAsofMergeSortJoinOperator.java
index 0f880ba2f8886..23e1a9c69c3b7 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/AbstractAsofMergeSortJoinOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/AbstractAsofMergeSortJoinOperator.java
@@ -17,11 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational;
+package org.apache.iotdb.calc.execution.operator.source.relational;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator.JoinKeyComparator;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.join.merge.comparator.JoinKeyComparator;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.read.common.block.TsBlock;
@@ -34,7 +34,7 @@ public abstract class AbstractAsofMergeSortJoinOperator extends AbstractMergeSor
private final int rightAsofJoinKeyIndex;
public AbstractAsofMergeSortJoinOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator leftChild,
int[] leftJoinKeyPositions,
int[] leftOutputSymbolIdx,
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/AbstractMergeSortJoinOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/AbstractMergeSortJoinOperator.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/AbstractMergeSortJoinOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/AbstractMergeSortJoinOperator.java
index 1f41ddaeb8150..bd12e7fc71ed5 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/AbstractMergeSortJoinOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/AbstractMergeSortJoinOperator.java
@@ -17,13 +17,14 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational;
+package org.apache.iotdb.calc.execution.operator.source.relational;
-import org.apache.iotdb.db.queryengine.execution.operator.AbstractOperator;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator.JoinKeyComparator;
-import org.apache.iotdb.db.queryengine.plan.planner.memory.MemoryReservationManager;
+import org.apache.iotdb.calc.execution.operator.AbstractOperator;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.join.merge.comparator.JoinKeyComparator;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
+import org.apache.iotdb.calc.plan.planner.memory.MemoryReservationManager;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.block.column.ColumnBuilder;
@@ -37,8 +38,7 @@
import java.util.concurrent.TimeUnit;
import static com.google.common.util.concurrent.Futures.successfulAsList;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator.TIME_COLUMN_TEMPLATE;
-import static org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanGraphPrinter.MAX_RESERVED_MEMORY;
+import static org.apache.iotdb.calc.plan.planner.CommonOperatorUtils.MAX_RESERVED_MEMORY;
public abstract class AbstractMergeSortJoinOperator extends AbstractOperator {
protected boolean leftFinished;
@@ -67,7 +67,7 @@ public abstract class AbstractMergeSortJoinOperator extends AbstractOperator {
protected long usedMemory;
protected AbstractMergeSortJoinOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator leftChild,
int[] leftJoinKeyPositions,
int[] leftOutputSymbolIdx,
@@ -85,11 +85,7 @@ protected AbstractMergeSortJoinOperator(
this.rightOutputSymbolIdx = rightOutputSymbolIdx;
this.comparators = comparators;
- this.memoryReservationManager =
- operatorContext
- .getDriverContext()
- .getFragmentInstanceContext()
- .getMemoryReservationContext();
+ this.memoryReservationManager = operatorContext.getMemoryReservationContext();
this.resultBuilder = new TsBlockBuilder(dataTypes);
}
@@ -564,7 +560,8 @@ protected void appendOneLeftRowWithEmptyRight() {
protected void buildResultTsBlock() {
resultTsBlock =
resultBuilder.build(
- new RunLengthEncodedColumn(TIME_COLUMN_TEMPLATE, resultBuilder.getPositionCount()));
+ new RunLengthEncodedColumn(
+ CommonOperatorUtils.TIME_COLUMN_TEMPLATE, resultBuilder.getPositionCount()));
resultBuilder.reset();
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/AsofMergeSortInnerJoinOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/AsofMergeSortInnerJoinOperator.java
similarity index 89%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/AsofMergeSortInnerJoinOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/AsofMergeSortInnerJoinOperator.java
index f8a57dd3c4076..2090fdf055f03 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/AsofMergeSortInnerJoinOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/AsofMergeSortInnerJoinOperator.java
@@ -17,12 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational;
+package org.apache.iotdb.calc.execution.operator.source.relational;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator.JoinKeyComparator;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.join.merge.comparator.JoinKeyComparator;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.utils.RamUsageEstimator;
@@ -34,7 +34,7 @@ public class AsofMergeSortInnerJoinOperator extends AbstractAsofMergeSortJoinOpe
RamUsageEstimator.shallowSizeOfInstance(AsofMergeSortInnerJoinOperator.class);
public AsofMergeSortInnerJoinOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator leftChild,
int[] leftJoinKeyPositions,
int[] leftOutputSymbolIdx,
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/AsofMergeSortLeftJoinOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/AsofMergeSortLeftJoinOperator.java
similarity index 90%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/AsofMergeSortLeftJoinOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/AsofMergeSortLeftJoinOperator.java
index 8307c242163cc..7658aa2f5a373 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/AsofMergeSortLeftJoinOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/AsofMergeSortLeftJoinOperator.java
@@ -17,12 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational;
+package org.apache.iotdb.calc.execution.operator.source.relational;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator.JoinKeyComparator;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.join.merge.comparator.JoinKeyComparator;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.utils.RamUsageEstimator;
@@ -34,7 +34,7 @@ public class AsofMergeSortLeftJoinOperator extends AbstractAsofMergeSortJoinOper
RamUsageEstimator.shallowSizeOfInstance(AsofMergeSortLeftJoinOperator.class);
public AsofMergeSortLeftJoinOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator leftChild,
int[] leftJoinKeyPositions,
int[] leftOutputSymbolIdx,
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/MarkDistinctOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/MarkDistinctOperator.java
similarity index 81%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/MarkDistinctOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/MarkDistinctOperator.java
index 4794f97c885d0..c37015ee1f5f4 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/MarkDistinctOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/MarkDistinctOperator.java
@@ -17,15 +17,15 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational;
+package org.apache.iotdb.calc.execution.operator.source.relational;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.ProcessOperator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.UpdateMemory;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.hash.MarkDistinctHash;
-import org.apache.iotdb.db.queryengine.plan.planner.memory.MemoryReservationManager;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.ProcessOperator;
+import org.apache.iotdb.calc.plan.planner.memory.MemoryReservationManager;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
+import org.apache.iotdb.commons.queryengine.execution.operator.source.relational.aggregation.grouped.UpdateMemory;
+import org.apache.iotdb.commons.queryengine.execution.operator.source.relational.aggregation.grouped.hash.MarkDistinctHash;
import com.google.common.collect.ImmutableList;
import com.google.common.primitives.Ints;
@@ -40,13 +40,13 @@
import java.util.Optional;
import static java.util.Objects.requireNonNull;
-import static org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanGraphPrinter.CURRENT_USED_MEMORY;
+import static org.apache.iotdb.calc.plan.planner.CommonOperatorUtils.CURRENT_USED_MEMORY;
public class MarkDistinctOperator implements ProcessOperator {
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(MarkDistinctOperator.class);
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
private final Operator child;
@@ -61,7 +61,7 @@ public class MarkDistinctOperator implements ProcessOperator {
TSFileDescriptor.getInstance().getConfig().getMaxTsBlockLineNumber();
public MarkDistinctOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator child,
List types,
List markDistinctChannels,
@@ -88,15 +88,11 @@ public MarkDistinctOperator(
this.markDistinctHash =
new MarkDistinctHash(distinctTypes.build(), hashChannel.isPresent(), UpdateMemory.NOOP);
- this.memoryReservationManager =
- operatorContext
- .getDriverContext()
- .getFragmentInstanceContext()
- .getMemoryReservationContext();
+ this.memoryReservationManager = operatorContext.getMemoryReservationContext();
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/MergeSortFullOuterJoinOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/MergeSortFullOuterJoinOperator.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/MergeSortFullOuterJoinOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/MergeSortFullOuterJoinOperator.java
index 337d90eebac7f..278d87ea02155 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/MergeSortFullOuterJoinOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/MergeSortFullOuterJoinOperator.java
@@ -17,12 +17,13 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational;
+package org.apache.iotdb.calc.execution.operator.source.relational;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator.JoinKeyComparator;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.join.merge.comparator.JoinKeyComparator;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
@@ -33,8 +34,6 @@
import java.util.List;
import java.util.function.BiFunction;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator.TIME_COLUMN_TEMPLATE;
-
public class MergeSortFullOuterJoinOperator extends AbstractMergeSortJoinOperator {
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(MergeSortFullOuterJoinOperator.class);
@@ -45,7 +44,7 @@ public class MergeSortFullOuterJoinOperator extends AbstractMergeSortJoinOperato
private final List> updateLastMatchedRowFunctions;
public MergeSortFullOuterJoinOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator leftChild,
int[] leftJoinKeyPositions,
int[] leftOutputSymbolIdx,
@@ -190,7 +189,7 @@ protected void recordsWhenDataMatches() {
.get(i)
.apply(leftBlock.getColumn(leftJoinKeyPositions[i]), leftIndex);
}
- lastMatchedRightBlock = new TsBlock(1, TIME_COLUMN_TEMPLATE, valueColumns);
+ lastMatchedRightBlock = new TsBlock(1, CommonOperatorUtils.TIME_COLUMN_TEMPLATE, valueColumns);
}
private void buildUseRemainingBlocks() {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/MergeSortInnerJoinOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/MergeSortInnerJoinOperator.java
similarity index 91%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/MergeSortInnerJoinOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/MergeSortInnerJoinOperator.java
index 3b7e17fae110c..03611237960b8 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/MergeSortInnerJoinOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/MergeSortInnerJoinOperator.java
@@ -17,12 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational;
+package org.apache.iotdb.calc.execution.operator.source.relational;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator.JoinKeyComparator;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.join.merge.comparator.JoinKeyComparator;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.read.common.block.TsBlock;
@@ -35,7 +35,7 @@ public class MergeSortInnerJoinOperator extends AbstractMergeSortJoinOperator {
RamUsageEstimator.shallowSizeOfInstance(MergeSortInnerJoinOperator.class);
public MergeSortInnerJoinOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator leftChild,
int[] leftJoinKeyPositions,
int[] leftOutputSymbolIdx,
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/MergeSortLeftJoinOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/MergeSortLeftJoinOperator.java
similarity index 91%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/MergeSortLeftJoinOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/MergeSortLeftJoinOperator.java
index be6cb2f3a51be..6461606095afb 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/MergeSortLeftJoinOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/MergeSortLeftJoinOperator.java
@@ -17,12 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational;
+package org.apache.iotdb.calc.execution.operator.source.relational;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator.JoinKeyComparator;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.join.merge.comparator.JoinKeyComparator;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.utils.RamUsageEstimator;
@@ -34,7 +34,7 @@ public class MergeSortLeftJoinOperator extends AbstractMergeSortJoinOperator {
RamUsageEstimator.shallowSizeOfInstance(MergeSortLeftJoinOperator.class);
public MergeSortLeftJoinOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator leftChild,
int[] leftJoinKeyPositions,
int[] leftOutputSymbolIdx,
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/MergeSortSemiJoinOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/MergeSortSemiJoinOperator.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/MergeSortSemiJoinOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/MergeSortSemiJoinOperator.java
index b21ed578965fe..35d9c061b38b9 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/MergeSortSemiJoinOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/MergeSortSemiJoinOperator.java
@@ -17,12 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational;
+package org.apache.iotdb.calc.execution.operator.source.relational;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.comparator.JoinKeyComparator;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.join.merge.comparator.JoinKeyComparator;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import org.apache.tsfile.block.column.ColumnBuilder;
import org.apache.tsfile.enums.TSDataType;
@@ -40,7 +40,7 @@ public class MergeSortSemiJoinOperator extends AbstractMergeSortJoinOperator {
private boolean rightHasNullValue = false;
public MergeSortSemiJoinOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator leftChild,
int leftJoinKeyPosition,
int[] leftOutputSymbolIdx,
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/AbstractApproxMostFrequentAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/AbstractApproxMostFrequentAccumulator.java
similarity index 88%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/AbstractApproxMostFrequentAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/AbstractApproxMostFrequentAccumulator.java
index 68128c94f58c5..07c640f95caad 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/AbstractApproxMostFrequentAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/AbstractApproxMostFrequentAccumulator.java
@@ -12,9 +12,9 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSavingStateFactory;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSavingStateFactory;
import com.google.gson.Gson;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/AbstractApproxPercentileAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/AbstractApproxPercentileAccumulator.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/AbstractApproxPercentileAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/AbstractApproxPercentileAccumulator.java
index df8b723638281..cec628de50a70 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/AbstractApproxPercentileAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/AbstractApproxPercentileAccumulator.java
@@ -12,10 +12,10 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.TDigest;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.TDigest;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/AccumulatorFactory.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/AccumulatorFactory.java
similarity index 84%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/AccumulatorFactory.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/AccumulatorFactory.java
index 15b3d8da38fdd..48a1abc83f38e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/AccumulatorFactory.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/AccumulatorFactory.java
@@ -17,44 +17,44 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
-
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
+
+import org.apache.iotdb.calc.execution.aggregation.VarianceAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.BinaryGroupedApproxMostFrequentAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.BlobGroupedApproxMostFrequentAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.BooleanGroupedApproxMostFrequentAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.DoubleGroupedApproxMostFrequentAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.FloatGroupedApproxMostFrequentAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedApproxCountDistinctAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedApproxPercentileAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedApproxPercentileWithWeightAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedAvgAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedCountAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedCountAllAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedCountIfAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedExtremeAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedFirstAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedFirstByAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedLastAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedLastByAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedMaxAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedMaxByAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedMinAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedMinByAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedModeAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedSumAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedUserDefinedAggregateAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedVarianceAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.IntGroupedApproxMostFrequentAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.LongGroupedApproxMostFrequentAccumulator;
import org.apache.iotdb.common.rpc.thrift.TAggregationType;
+import org.apache.iotdb.commons.queryengine.execution.operator.source.relational.aggregation.grouped.UpdateMemory;
+import org.apache.iotdb.commons.queryengine.execution.operator.source.relational.aggregation.grouped.hash.MarkDistinctHash;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.Expression;
+import org.apache.iotdb.commons.queryengine.plan.relational.type.InternalTypeManager;
+import org.apache.iotdb.commons.queryengine.plan.udf.TableUDFUtils;
import org.apache.iotdb.commons.udf.utils.UDFDataTypeTransformer;
-import org.apache.iotdb.db.queryengine.execution.aggregation.VarianceAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.BinaryGroupedApproxMostFrequentAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.BlobGroupedApproxMostFrequentAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.BooleanGroupedApproxMostFrequentAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.DoubleGroupedApproxMostFrequentAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.FloatGroupedApproxMostFrequentAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedApproxCountDistinctAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedApproxPercentileAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedApproxPercentileWithWeightAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedAvgAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedCountAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedCountAllAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedCountIfAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedExtremeAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedFirstAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedFirstByAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedLastAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedLastByAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedMaxAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedMaxByAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedMinAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedMinByAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedModeAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedSumAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedUserDefinedAggregateAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedVarianceAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.IntGroupedApproxMostFrequentAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.LongGroupedApproxMostFrequentAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.UpdateMemory;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.hash.MarkDistinctHash;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Expression;
-import org.apache.iotdb.db.queryengine.plan.relational.type.InternalTypeManager;
-import org.apache.iotdb.db.queryengine.plan.udf.TableUDFUtils;
import org.apache.iotdb.udf.api.customizer.parameter.FunctionArguments;
import org.apache.iotdb.udf.api.relational.AggregateFunction;
@@ -78,12 +78,12 @@
import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;
+import static org.apache.iotdb.calc.plan.relational.planner.ir.GlobalTimePredicateExtractVisitor.isMeasurementColumn;
+import static org.apache.iotdb.calc.plan.relational.planner.ir.GlobalTimePredicateExtractVisitor.isTimeColumn;
import static org.apache.iotdb.commons.udf.builtin.relational.TableBuiltinAggregationFunction.FIRST;
import static org.apache.iotdb.commons.udf.builtin.relational.TableBuiltinAggregationFunction.FIRST_BY;
import static org.apache.iotdb.commons.udf.builtin.relational.TableBuiltinAggregationFunction.LAST;
import static org.apache.iotdb.commons.udf.builtin.relational.TableBuiltinAggregationFunction.LAST_BY;
-import static org.apache.iotdb.db.queryengine.plan.relational.planner.ir.GlobalTimePredicateExtractVisitor.isMeasurementColumn;
-import static org.apache.iotdb.db.queryengine.plan.relational.planner.ir.GlobalTimePredicateExtractVisitor.isTimeColumn;
import static org.apache.tsfile.read.common.type.IntType.INT32;
public class AccumulatorFactory {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/AggregationMask.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/AggregationMask.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/AggregationMask.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/AggregationMask.java
index 8b439f5d0d746..fd8e6db4e7d2f 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/AggregationMask.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/AggregationMask.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.read.common.block.column.RunLengthEncodedColumn;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/AggregationOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/AggregationOperator.java
similarity index 80%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/AggregationOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/AggregationOperator.java
index d2ec8af83ffc3..e65ee82517d4c 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/AggregationOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/AggregationOperator.java
@@ -17,14 +17,14 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.process.ProcessOperator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator;
-import org.apache.iotdb.db.queryengine.plan.planner.memory.MemoryReservationManager;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.ProcessOperator;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
+import org.apache.iotdb.calc.plan.planner.memory.MemoryReservationManager;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.block.column.Column;
@@ -43,7 +43,7 @@ public class AggregationOperator implements ProcessOperator {
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(AggregationOperator.class);
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
private final Operator child;
@@ -61,7 +61,7 @@ public class AggregationOperator implements ProcessOperator {
private boolean finished = false;
public AggregationOperator(
- OperatorContext operatorContext, Operator child, List aggregators) {
+ CommonOperatorContext operatorContext, Operator child, List aggregators) {
this.operatorContext = operatorContext;
this.child = child;
this.aggregators = aggregators;
@@ -69,11 +69,7 @@ public AggregationOperator(
new TsBlockBuilder(
aggregators.stream().map(TableAggregator::getType).collect(toImmutableList()));
this.resultColumnsBuilder = resultBuilder.getValueColumnBuilders();
- this.memoryReservationManager =
- operatorContext
- .getDriverContext()
- .getFragmentInstanceContext()
- .getMemoryReservationContext();
+ this.memoryReservationManager = operatorContext.getMemoryReservationContext();
}
@Override
@@ -111,7 +107,7 @@ public TsBlock next() throws Exception {
finished = true;
return TsBlock.wrapBlocksWithoutCopy(
- 1, new RunLengthEncodedColumn(TableScanOperator.TIME_COLUMN_TEMPLATE, 1), valueColumns);
+ 1, new RunLengthEncodedColumn(CommonOperatorUtils.TIME_COLUMN_TEMPLATE, 1), valueColumns);
}
}
@@ -127,7 +123,7 @@ public void close() throws Exception {
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/ApproxCountDistinctAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/ApproxCountDistinctAccumulator.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/ApproxCountDistinctAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/ApproxCountDistinctAccumulator.java
index ef31759ee677b..5c2dfcf62d72c 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/ApproxCountDistinctAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/ApproxCountDistinctAccumulator.java
@@ -12,10 +12,10 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.HyperLogLog;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.HyperLogLogStateFactory;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.HyperLogLog;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.HyperLogLogStateFactory;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
@@ -27,7 +27,7 @@
import org.apache.tsfile.write.UnSupportedDataTypeException;
import static com.google.common.base.Preconditions.checkArgument;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.HyperLogLog.DEFAULT_STANDARD_ERROR;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.HyperLogLog.DEFAULT_STANDARD_ERROR;
public class ApproxCountDistinctAccumulator implements TableAccumulator {
private static final long INSTANCE_SIZE =
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/ApproxPercentileAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/ApproxPercentileAccumulator.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/ApproxPercentileAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/ApproxPercentileAccumulator.java
index 2f95942caa4a1..3fb28f95d54c4 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/ApproxPercentileAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/ApproxPercentileAccumulator.java
@@ -12,7 +12,7 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.enums.TSDataType;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/ApproxPercentileWithWeightAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/ApproxPercentileWithWeightAccumulator.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/ApproxPercentileWithWeightAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/ApproxPercentileWithWeightAccumulator.java
index f52165472f7ec..604971b0d6b0a 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/ApproxPercentileWithWeightAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/ApproxPercentileWithWeightAccumulator.java
@@ -12,9 +12,9 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
-import org.apache.iotdb.db.exception.sql.SemanticException;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.enums.TSDataType;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/AvgAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/AvgAccumulator.java
similarity index 99%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/AvgAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/AvgAccumulator.java
index 7bb03faadeb7d..9d142151a1053 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/AvgAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/AvgAccumulator.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/BinaryApproxMostFrequentAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/BinaryApproxMostFrequentAccumulator.java
similarity index 89%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/BinaryApproxMostFrequentAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/BinaryApproxMostFrequentAccumulator.java
index 1fe0370a4dba4..43be7d759f516 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/BinaryApproxMostFrequentAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/BinaryApproxMostFrequentAccumulator.java
@@ -12,12 +12,12 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.Counter;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSavingStateFactory;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.Counter;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSavingStateFactory;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.utils.Binary;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/BlobApproxMostFrequentAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/BlobApproxMostFrequentAccumulator.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/BlobApproxMostFrequentAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/BlobApproxMostFrequentAccumulator.java
index 67ce419e2839c..f0c8a768f4306 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/BlobApproxMostFrequentAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/BlobApproxMostFrequentAccumulator.java
@@ -12,7 +12,7 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import com.google.gson.Gson;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/BooleanApproxMostFrequentAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/BooleanApproxMostFrequentAccumulator.java
similarity index 89%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/BooleanApproxMostFrequentAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/BooleanApproxMostFrequentAccumulator.java
index f080157e82f94..94c01c33abdb6 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/BooleanApproxMostFrequentAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/BooleanApproxMostFrequentAccumulator.java
@@ -12,12 +12,12 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.Counter;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSavingStateFactory;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.Counter;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSavingStateFactory;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/CountAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/CountAccumulator.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/CountAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/CountAccumulator.java
index ce85c22363232..68918a1e68ab8 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/CountAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/CountAccumulator.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/CountAllAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/CountAllAccumulator.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/CountAllAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/CountAllAccumulator.java
index f72cea243580d..f7bae4c3bba55 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/CountAllAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/CountAllAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/CountIfAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/CountIfAccumulator.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/CountIfAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/CountIfAccumulator.java
index 1aff9106c7284..db7e958ddc799 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/CountIfAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/CountIfAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/DoubleApproxMostFrequentAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/DoubleApproxMostFrequentAccumulator.java
similarity index 89%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/DoubleApproxMostFrequentAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/DoubleApproxMostFrequentAccumulator.java
index 52444a88d9a27..acde2e22314c1 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/DoubleApproxMostFrequentAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/DoubleApproxMostFrequentAccumulator.java
@@ -12,12 +12,12 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.Counter;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSavingStateFactory;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.Counter;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSavingStateFactory;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/ExtremeAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/ExtremeAccumulator.java
similarity index 99%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/ExtremeAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/ExtremeAccumulator.java
index f2fdf2439bae3..85fbee4bd5ea9 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/ExtremeAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/ExtremeAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/FirstAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/FirstAccumulator.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/FirstAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/FirstAccumulator.java
index d1f04cfdc920f..778b6b9253137 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/FirstAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/FirstAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
@@ -36,7 +36,7 @@
import java.nio.charset.StandardCharsets;
import static com.google.common.base.Preconditions.checkArgument;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.Utils.serializeTimeValueWithNull;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.Utils.serializeTimeValueWithNull;
public class FirstAccumulator implements TableAccumulator {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/FirstByAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/FirstByAccumulator.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/FirstByAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/FirstByAccumulator.java
index 90057390a9b25..81482c897b41a 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/FirstByAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/FirstByAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
@@ -35,7 +35,7 @@
import java.nio.charset.StandardCharsets;
import static com.google.common.base.Preconditions.checkArgument;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.Utils.serializeTimeValueWithNull;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.Utils.serializeTimeValueWithNull;
public class FirstByAccumulator implements TableAccumulator {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/FirstByDescAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/FirstByDescAccumulator.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/FirstByDescAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/FirstByDescAccumulator.java
index c6f310048adb0..c45a9255dc2dc 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/FirstByDescAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/FirstByDescAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.enums.TSDataType;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/FirstDescAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/FirstDescAccumulator.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/FirstDescAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/FirstDescAccumulator.java
index 17103ab683898..1066c91614562 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/FirstDescAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/FirstDescAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.enums.TSDataType;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/FloatApproxMostFrequentAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/FloatApproxMostFrequentAccumulator.java
similarity index 89%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/FloatApproxMostFrequentAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/FloatApproxMostFrequentAccumulator.java
index 5515158516628..7c3d581e597f9 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/FloatApproxMostFrequentAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/FloatApproxMostFrequentAccumulator.java
@@ -12,12 +12,12 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.Counter;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSavingStateFactory;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.Counter;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSavingStateFactory;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/IntApproxMostFrequentAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/IntApproxMostFrequentAccumulator.java
similarity index 89%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/IntApproxMostFrequentAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/IntApproxMostFrequentAccumulator.java
index 283cbd18d6997..76ab725dd1034 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/IntApproxMostFrequentAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/IntApproxMostFrequentAccumulator.java
@@ -12,12 +12,12 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.Counter;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSavingStateFactory;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.Counter;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSavingStateFactory;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/LastAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/LastAccumulator.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/LastAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/LastAccumulator.java
index 4da324e8b0372..0899f38993d6d 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/LastAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/LastAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
@@ -36,7 +36,7 @@
import java.nio.charset.StandardCharsets;
import static com.google.common.base.Preconditions.checkArgument;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.Utils.serializeTimeValueWithNull;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.Utils.serializeTimeValueWithNull;
public class LastAccumulator implements TableAccumulator {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/LastByAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/LastByAccumulator.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/LastByAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/LastByAccumulator.java
index 711b5efd13a2e..580bebcc59160 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/LastByAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/LastByAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
@@ -33,7 +33,7 @@
import org.apache.tsfile.write.UnSupportedDataTypeException;
import static com.google.common.base.Preconditions.checkArgument;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.Utils.serializeTimeValueWithNull;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.Utils.serializeTimeValueWithNull;
public class LastByAccumulator implements TableAccumulator {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/LastByDescAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/LastByDescAccumulator.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/LastByDescAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/LastByDescAccumulator.java
index d664f2286d6a8..edb7165f9c41c 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/LastByDescAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/LastByDescAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.enums.TSDataType;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/LastDescAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/LastDescAccumulator.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/LastDescAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/LastDescAccumulator.java
index 80c1227056f49..de1d6dfd18ef5 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/LastDescAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/LastDescAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.enums.TSDataType;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/LongApproxMostFrequentAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/LongApproxMostFrequentAccumulator.java
similarity index 89%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/LongApproxMostFrequentAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/LongApproxMostFrequentAccumulator.java
index 348a6aeb646ef..bbb11f213e7c2 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/LongApproxMostFrequentAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/LongApproxMostFrequentAccumulator.java
@@ -12,12 +12,12 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.Counter;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSavingStateFactory;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.Counter;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSavingStateFactory;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/MaskedRecordIterator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/MaskedRecordIterator.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/MaskedRecordIterator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/MaskedRecordIterator.java
index 48095927eda56..2534b995a2883 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/MaskedRecordIterator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/MaskedRecordIterator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.read.common.type.Type;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/MaxAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/MaxAccumulator.java
similarity index 99%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/MaxAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/MaxAccumulator.java
index 373fc9bd26437..26b599fbb730f 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/MaxAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/MaxAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/MinAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/MinAccumulator.java
similarity index 99%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/MinAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/MinAccumulator.java
index 8f2a7113b7bcc..00a922c4eac47 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/MinAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/MinAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/RecordIterator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/RecordIterator.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/RecordIterator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/RecordIterator.java
index fcb0bf93cfd9b..e0e27aa763cac 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/RecordIterator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/RecordIterator.java
@@ -17,10 +17,10 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
+import org.apache.iotdb.calc.utils.ObjectTypeUtils;
import org.apache.iotdb.commons.udf.utils.UDFDataTypeTransformer;
-import org.apache.iotdb.db.utils.ObjectTypeUtils;
import org.apache.iotdb.udf.api.relational.access.Record;
import org.apache.iotdb.udf.api.type.Type;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/SumAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/SumAccumulator.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/SumAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/SumAccumulator.java
index 6f42e1a9995f3..0c392ebaa2b68 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/SumAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/SumAccumulator.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableAccumulator.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableAccumulator.java
index 7858c53c0331b..9699ba1782933 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableAggregator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableAggregator.java
similarity index 86%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableAggregator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableAggregator.java
index 955532cea6d71..1df3f6fb159b4 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableAggregator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableAggregator.java
@@ -17,9 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.node.AggregationNode;
+import org.apache.iotdb.calc.metric.QueryExecutionMetricSet;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.AggregationNode;
import com.google.common.primitives.Ints;
import org.apache.tsfile.block.column.Column;
@@ -34,11 +36,13 @@
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
-import static org.apache.iotdb.db.queryengine.execution.aggregation.TreeAggregator.QUERY_EXECUTION_METRICS;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator.TIME_COLUMN_TEMPLATE;
-import static org.apache.iotdb.db.queryengine.metric.QueryExecutionMetricSet.AGGREGATION_FROM_RAW_DATA;
+import static org.apache.iotdb.calc.metric.QueryExecutionMetricSet.AGGREGATION_FROM_RAW_DATA;
public class TableAggregator {
+
+ public static final QueryExecutionMetricSet QUERY_EXECUTION_METRICS =
+ QueryExecutionMetricSet.getInstance();
+
private final TableAccumulator accumulator;
private final AggregationNode.Step step;
private final TSDataType outputType;
@@ -74,7 +78,8 @@ public void processBlock(TsBlock block) {
if (arguments.length == 0) {
arguments =
new Column[] {
- new RunLengthEncodedColumn(TIME_COLUMN_TEMPLATE, block.getPositionCount())
+ new RunLengthEncodedColumn(
+ CommonOperatorUtils.TIME_COLUMN_TEMPLATE, block.getPositionCount())
};
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableMaxByAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableMaxByAccumulator.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableMaxByAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableMaxByAccumulator.java
index ef0ebbb2b7955..6fb43a11b67a6 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableMaxByAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableMaxByAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.utils.Binary;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableMaxMinByBaseAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableMaxMinByBaseAccumulator.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableMaxMinByBaseAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableMaxMinByBaseAccumulator.java
index c6002304b1070..d6df22858df4b 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableMaxMinByBaseAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableMaxMinByBaseAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
@@ -35,8 +35,8 @@
import java.util.Collections;
import static com.google.common.base.Preconditions.checkArgument;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.Utils.calcTypeSize;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.Utils.serializeValue;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.Utils.calcTypeSize;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.Utils.serializeValue;
/** max(x,y) returns the value of x associated with the maximum value of y over all input values. */
public abstract class TableMaxMinByBaseAccumulator implements TableAccumulator {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableMinByAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableMinByAccumulator.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableMinByAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableMinByAccumulator.java
index d4fbadae512e2..4de2b2e66b834 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableMinByAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableMinByAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.utils.Binary;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableModeAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableModeAccumulator.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableModeAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableModeAccumulator.java
index adb47e41231a7..c7d1a13039110 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableModeAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableModeAccumulator.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
@@ -36,15 +36,15 @@
import java.util.Map;
import static com.google.common.base.Preconditions.checkArgument;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.Utils.UNSUPPORTED_TYPE_MESSAGE;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.Utils.serializeBinaryValue;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.Utils.UNSUPPORTED_TYPE_MESSAGE;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.Utils.serializeBinaryValue;
import static org.apache.tsfile.utils.BytesUtils.bytesToBool;
import static org.apache.tsfile.utils.BytesUtils.bytesToLongFromOffset;
public class TableModeAccumulator implements TableAccumulator {
private final int MAP_SIZE_THRESHOLD =
- IoTDBDescriptor.getInstance().getConfig().getModeMapSizeThreshold();
+ CommonDescriptor.getInstance().getConfig().getModeMapSizeThreshold();
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(TableModeAccumulator.class);
private final TSDataType seriesDataType;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableVarianceAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableVarianceAccumulator.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableVarianceAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableVarianceAccumulator.java
index 92ea803f2d0ac..ef186d8d3fbcb 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/TableVarianceAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/TableVarianceAccumulator.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
-import org.apache.iotdb.db.queryengine.execution.aggregation.VarianceAccumulator;
+import org.apache.iotdb.calc.execution.aggregation.VarianceAccumulator;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/UserDefinedAggregateFunctionAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/UserDefinedAggregateFunctionAccumulator.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/UserDefinedAggregateFunctionAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/UserDefinedAggregateFunctionAccumulator.java
index 70e1c0c5d4432..234b1bae2580e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/UserDefinedAggregateFunctionAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/UserDefinedAggregateFunctionAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.iotdb.udf.api.State;
import org.apache.iotdb.udf.api.customizer.analysis.AggregateFunctionAnalysis;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/Utils.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/Utils.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/Utils.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/Utils.java
index c6c4b365637ca..a74d402f54088 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/Utils.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/Utils.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.utils.Binary;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/ApproxMostFrequentBucketDeserializer.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/ApproxMostFrequentBucketDeserializer.java
similarity index 87%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/ApproxMostFrequentBucketDeserializer.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/ApproxMostFrequentBucketDeserializer.java
index 6a2b4ad4d2b7a..cdcb48938d6b0 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/ApproxMostFrequentBucketDeserializer.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/ApproxMostFrequentBucketDeserializer.java
@@ -12,7 +12,7 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate;
import java.nio.ByteBuffer;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/ApproxMostFrequentBucketSerializer.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/ApproxMostFrequentBucketSerializer.java
similarity index 87%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/ApproxMostFrequentBucketSerializer.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/ApproxMostFrequentBucketSerializer.java
index 87377252bf3a1..3aa721b24f24f 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/ApproxMostFrequentBucketSerializer.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/ApproxMostFrequentBucketSerializer.java
@@ -12,7 +12,7 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate;
import java.nio.ByteBuffer;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/Counter.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/Counter.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/Counter.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/Counter.java
index 319c8bc8e31c5..93d1c9514478e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/Counter.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/Counter.java
@@ -12,7 +12,7 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate;
import java.io.Externalizable;
import java.io.IOException;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/DoublyLinkedList.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/DoublyLinkedList.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/DoublyLinkedList.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/DoublyLinkedList.java
index 2aa2e47efcdae..ef4bf76496b1e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/DoublyLinkedList.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/DoublyLinkedList.java
@@ -12,7 +12,7 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/ExternalizableUtil.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/ExternalizableUtil.java
similarity index 90%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/ExternalizableUtil.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/ExternalizableUtil.java
index e0de4b6e66ffe..0f8bbd56a9379 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/ExternalizableUtil.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/ExternalizableUtil.java
@@ -12,7 +12,7 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate;
import java.io.ByteArrayOutputStream;
import java.io.Externalizable;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/HyperLogLog.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/HyperLogLog.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/HyperLogLog.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/HyperLogLog.java
index e4ffb4a71880c..588f8fdb9baab 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/HyperLogLog.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/HyperLogLog.java
@@ -12,7 +12,7 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate;
import org.apache.iotdb.commons.exception.IoTDBRuntimeException;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/HyperLogLogStateFactory.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/HyperLogLogStateFactory.java
similarity index 91%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/HyperLogLogStateFactory.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/HyperLogLogStateFactory.java
index b7e88d0c3a79a..77cf63096e31a 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/HyperLogLogStateFactory.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/HyperLogLogStateFactory.java
@@ -12,9 +12,9 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.HyperLogLogBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.HyperLogLogBigArray;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/ITopK.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/ITopK.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/ITopK.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/ITopK.java
index 8624551aa5415..560ae76511989 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/ITopK.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/ITopK.java
@@ -12,7 +12,7 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate;
import java.util.List;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/ListNode2.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/ListNode2.java
similarity index 90%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/ListNode2.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/ListNode2.java
index 09c5c7d449730..57683f9ebceab 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/ListNode2.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/ListNode2.java
@@ -12,7 +12,7 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate;
public class ListNode2 {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/Pair.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/Pair.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/Pair.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/Pair.java
index 3bb4d8000f0be..efa9ec8386da6 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/Pair.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/Pair.java
@@ -12,7 +12,7 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate;
public class Pair {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/SpaceSaving.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/SpaceSaving.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/SpaceSaving.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/SpaceSaving.java
index 5f5cddf574725..640c81d7908d3 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/SpaceSaving.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/SpaceSaving.java
@@ -12,7 +12,7 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate;
import com.google.common.collect.ImmutableMap;
import org.apache.tsfile.utils.ReadWriteIOUtils;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/SpaceSavingByteCalculator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/SpaceSavingByteCalculator.java
similarity index 87%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/SpaceSavingByteCalculator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/SpaceSavingByteCalculator.java
index a2388cf02c236..617250a17d15c 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/SpaceSavingByteCalculator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/SpaceSavingByteCalculator.java
@@ -12,7 +12,7 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate;
import java.util.List;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/SpaceSavingStateFactory.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/SpaceSavingStateFactory.java
similarity index 87%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/SpaceSavingStateFactory.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/SpaceSavingStateFactory.java
index 4a13fc316c610..82ad8411b5cf8 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/SpaceSavingStateFactory.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/SpaceSavingStateFactory.java
@@ -12,14 +12,14 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.SpaceSavingBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.SpaceSavingBigArray;
import org.apache.tsfile.utils.RamUsageEstimator;
import static java.util.Objects.requireNonNull;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSaving.getDefaultEstimatedSize;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSaving.getDefaultEstimatedSize;
public class SpaceSavingStateFactory {
public static SingleSpaceSavingState createSingleState() {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/StreamSummary.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/StreamSummary.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/StreamSummary.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/StreamSummary.java
index afd1c7468ced6..e91d8c4bd51e6 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/StreamSummary.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/StreamSummary.java
@@ -12,7 +12,7 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate;
import java.io.ByteArrayInputStream;
import java.io.Externalizable;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/TDigest.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/TDigest.java
similarity index 99%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/TDigest.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/TDigest.java
index f240c156c5234..7578238a84a5f 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/TDigest.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/approximate/TDigest.java
@@ -12,9 +12,9 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate;
-import org.apache.iotdb.db.exception.sql.SemanticException;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/AbstractGroupedApproxMostFrequentAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/AbstractGroupedApproxMostFrequentAccumulator.java
similarity index 85%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/AbstractGroupedApproxMostFrequentAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/AbstractGroupedApproxMostFrequentAccumulator.java
index 30542c0e87586..6a8a33079f296 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/AbstractGroupedApproxMostFrequentAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/AbstractGroupedApproxMostFrequentAccumulator.java
@@ -12,10 +12,10 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSavingStateFactory;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.SpaceSavingBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSavingStateFactory;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.SpaceSavingBigArray;
import com.google.gson.Gson;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/AbstractGroupedApproxPercentileAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/AbstractGroupedApproxPercentileAccumulator.java
similarity index 91%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/AbstractGroupedApproxPercentileAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/AbstractGroupedApproxPercentileAccumulator.java
index 4350c7a7aed2f..dd02ccda123e5 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/AbstractGroupedApproxPercentileAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/AbstractGroupedApproxPercentileAccumulator.java
@@ -12,11 +12,11 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.TDigest;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.TDigestBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.TDigest;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.TDigestBigArray;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/BinaryGroupedApproxMostFrequentAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/BinaryGroupedApproxMostFrequentAccumulator.java
similarity index 85%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/BinaryGroupedApproxMostFrequentAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/BinaryGroupedApproxMostFrequentAccumulator.java
index 85a39f1b51432..e70614133edd7 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/BinaryGroupedApproxMostFrequentAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/BinaryGroupedApproxMostFrequentAccumulator.java
@@ -12,13 +12,13 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.BinaryApproxMostFrequentAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.SpaceSavingBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.BinaryApproxMostFrequentAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.SpaceSavingBigArray;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.utils.Binary;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/BlobGroupedApproxMostFrequentAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/BlobGroupedApproxMostFrequentAccumulator.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/BlobGroupedApproxMostFrequentAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/BlobGroupedApproxMostFrequentAccumulator.java
index 1fb15d57444b6..0fd2de97e24ae 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/BlobGroupedApproxMostFrequentAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/BlobGroupedApproxMostFrequentAccumulator.java
@@ -12,7 +12,7 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
import com.google.gson.Gson;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/BooleanGroupedApproxMostFrequentAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/BooleanGroupedApproxMostFrequentAccumulator.java
similarity index 84%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/BooleanGroupedApproxMostFrequentAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/BooleanGroupedApproxMostFrequentAccumulator.java
index 59e01206d4364..2678bc4d7d841 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/BooleanGroupedApproxMostFrequentAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/BooleanGroupedApproxMostFrequentAccumulator.java
@@ -12,13 +12,13 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.BooleanApproxMostFrequentAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.SpaceSavingBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.BooleanApproxMostFrequentAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.SpaceSavingBigArray;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/DoubleGroupedApproxMostFrequentAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/DoubleGroupedApproxMostFrequentAccumulator.java
similarity index 84%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/DoubleGroupedApproxMostFrequentAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/DoubleGroupedApproxMostFrequentAccumulator.java
index 94fbc900855fc..fd8b19d2ed0ae 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/DoubleGroupedApproxMostFrequentAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/DoubleGroupedApproxMostFrequentAccumulator.java
@@ -12,13 +12,13 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.DoubleApproxMostFrequentAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.SpaceSavingBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.DoubleApproxMostFrequentAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.SpaceSavingBigArray;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/FloatGroupedApproxMostFrequentAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/FloatGroupedApproxMostFrequentAccumulator.java
similarity index 84%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/FloatGroupedApproxMostFrequentAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/FloatGroupedApproxMostFrequentAccumulator.java
index d463f7c280802..2df414c1dc623 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/FloatGroupedApproxMostFrequentAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/FloatGroupedApproxMostFrequentAccumulator.java
@@ -12,13 +12,13 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.FloatApproxMostFrequentAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.SpaceSavingBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.FloatApproxMostFrequentAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.SpaceSavingBigArray;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedAccumulator.java
similarity index 88%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedAccumulator.java
index c9c0c73d5c22d..0ec85621ac97b 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedAccumulator.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedAggregator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedAggregator.java
similarity index 87%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedAggregator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedAggregator.java
index e416d4f43f0ce..927d0249682fc 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedAggregator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedAggregator.java
@@ -17,10 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.node.AggregationNode;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.AggregationNode;
import com.google.common.primitives.Ints;
import org.apache.tsfile.block.column.Column;
@@ -34,7 +35,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator.TIME_COLUMN_TEMPLATE;
public class GroupedAggregator {
private final GroupedAccumulator accumulator;
@@ -70,7 +70,10 @@ public void processBlock(int groupCount, int[] groupIds, TsBlock block) {
// process count(*)
if (arguments.length == 0) {
arguments =
- new Column[] {new RunLengthEncodedColumn(TIME_COLUMN_TEMPLATE, block.getPositionCount())};
+ new Column[] {
+ new RunLengthEncodedColumn(
+ CommonOperatorUtils.TIME_COLUMN_TEMPLATE, block.getPositionCount())
+ };
}
if (step.isInputRaw()) {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedApproxCountDistinctAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedApproxCountDistinctAccumulator.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedApproxCountDistinctAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedApproxCountDistinctAccumulator.java
index 9fac50c2ad24c..c2422fbd3e3ab 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedApproxCountDistinctAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedApproxCountDistinctAccumulator.java
@@ -12,12 +12,12 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.HyperLogLog;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.HyperLogLogStateFactory;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.HyperLogLogBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.HyperLogLog;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.HyperLogLogStateFactory;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.HyperLogLogBigArray;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
@@ -26,7 +26,7 @@
import org.apache.tsfile.utils.RamUsageEstimator;
import org.apache.tsfile.write.UnSupportedDataTypeException;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.HyperLogLog.DEFAULT_STANDARD_ERROR;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.HyperLogLog.DEFAULT_STANDARD_ERROR;
public class GroupedApproxCountDistinctAccumulator implements GroupedAccumulator {
private static final long INSTANCE_SIZE =
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedApproxPercentileAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedApproxPercentileAccumulator.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedApproxPercentileAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedApproxPercentileAccumulator.java
index 9a2bfedf4eaf0..7899b963ea3c3 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedApproxPercentileAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedApproxPercentileAccumulator.java
@@ -12,10 +12,10 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.TDigest;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.TDigest;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.enums.TSDataType;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedApproxPercentileWithWeightAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedApproxPercentileWithWeightAccumulator.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedApproxPercentileWithWeightAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedApproxPercentileWithWeightAccumulator.java
index b7c587df0d0b4..d44b8a7d06710 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedApproxPercentileWithWeightAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedApproxPercentileWithWeightAccumulator.java
@@ -12,11 +12,11 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.TDigest;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.TDigest;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.enums.TSDataType;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedAvgAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedAvgAccumulator.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedAvgAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedAvgAccumulator.java
index 4e177c352b7de..0f23f7c913bc9 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedAvgAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedAvgAccumulator.java
@@ -16,11 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedCountAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedCountAccumulator.java
similarity index 89%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedCountAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedCountAccumulator.java
index 7ffc10a08a4f4..5420dbd06054c 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedCountAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedCountAccumulator.java
@@ -16,10 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedCountAllAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedCountAllAccumulator.java
similarity index 88%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedCountAllAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedCountAllAccumulator.java
index afa5c1e34e057..abd093ad22d2e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedCountAllAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedCountAllAccumulator.java
@@ -17,10 +17,10 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedCountIfAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedCountIfAccumulator.java
similarity index 89%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedCountIfAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedCountIfAccumulator.java
index b7ab8b3882c85..c6a87c7c4d880 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedCountIfAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedCountIfAccumulator.java
@@ -17,10 +17,10 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedExtremeAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedExtremeAccumulator.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedExtremeAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedExtremeAccumulator.java
index f53ea59314231..bd5aca876b7af 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedExtremeAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedExtremeAccumulator.java
@@ -17,14 +17,14 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BooleanBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.FloatBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.IntBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BooleanBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.FloatBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.IntBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedFirstAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedFirstAccumulator.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedFirstAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedFirstAccumulator.java
index 456b46c24ac19..b0c52d525018c 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedFirstAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedFirstAccumulator.java
@@ -17,15 +17,15 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
-
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BinaryBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BooleanBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.FloatBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.IntBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
+
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BinaryBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BooleanBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.FloatBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.IntBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedFirstByAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedFirstByAccumulator.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedFirstByAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedFirstByAccumulator.java
index fa713d07c9cb6..8364971fcea13 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedFirstByAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedFirstByAccumulator.java
@@ -17,15 +17,15 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
-
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BinaryBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BooleanBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.FloatBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.IntBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
+
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BinaryBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BooleanBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.FloatBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.IntBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedLastAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedLastAccumulator.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedLastAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedLastAccumulator.java
index 632e9fdb50ee0..c5696464da464 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedLastAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedLastAccumulator.java
@@ -17,15 +17,15 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
-
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BinaryBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BooleanBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.FloatBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.IntBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
+
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BinaryBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BooleanBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.FloatBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.IntBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedLastByAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedLastByAccumulator.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedLastByAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedLastByAccumulator.java
index cb628858d63ca..ab6ddae16cc72 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedLastByAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedLastByAccumulator.java
@@ -17,15 +17,15 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
-
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BinaryBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BooleanBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.FloatBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.IntBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
+
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BinaryBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BooleanBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.FloatBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.IntBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedMaxAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedMaxAccumulator.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedMaxAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedMaxAccumulator.java
index ed47c96d25137..119501e421391 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedMaxAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedMaxAccumulator.java
@@ -17,15 +17,15 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
-
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BinaryBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BooleanBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.FloatBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.IntBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
+
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BinaryBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BooleanBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.FloatBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.IntBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedMaxByAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedMaxByAccumulator.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedMaxByAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedMaxByAccumulator.java
index d46ad3ce41172..47c7297d54e58 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedMaxByAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedMaxByAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.utils.Binary;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedMaxMinByBaseAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedMaxMinByBaseAccumulator.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedMaxMinByBaseAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedMaxMinByBaseAccumulator.java
index b9b25f6271552..0f59a575f45c6 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedMaxMinByBaseAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedMaxMinByBaseAccumulator.java
@@ -17,15 +17,15 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
-
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BinaryBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BooleanBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.FloatBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.IntBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
+
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BinaryBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BooleanBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.FloatBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.IntBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedMinAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedMinAccumulator.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedMinAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedMinAccumulator.java
index 8fa9b4d8fa018..1993e2142fc76 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedMinAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedMinAccumulator.java
@@ -17,15 +17,15 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
-
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BinaryBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BooleanBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.FloatBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.IntBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
+
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BinaryBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BooleanBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.FloatBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.IntBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedMinByAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedMinByAccumulator.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedMinByAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedMinByAccumulator.java
index 3b8d48bbd4955..46f14dac9bf50 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedMinByAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedMinByAccumulator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.utils.Binary;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedModeAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedModeAccumulator.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedModeAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedModeAccumulator.java
index a5bf82c5f409b..4e6511ffff843 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedModeAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedModeAccumulator.java
@@ -17,12 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.MapBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.MapBigArray;
+import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
@@ -39,8 +39,8 @@
import java.util.Map;
import static com.google.common.base.Preconditions.checkArgument;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.Utils.UNSUPPORTED_TYPE_MESSAGE;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.Utils.serializeBinaryValue;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.Utils.UNSUPPORTED_TYPE_MESSAGE;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.Utils.serializeBinaryValue;
import static org.apache.tsfile.utils.BytesUtils.bytesToBool;
import static org.apache.tsfile.utils.BytesUtils.bytesToLongFromOffset;
import static org.apache.tsfile.utils.TsPrimitiveType.getByType;
@@ -48,7 +48,7 @@
public class GroupedModeAccumulator implements GroupedAccumulator {
private final int MAP_SIZE_THRESHOLD =
- IoTDBDescriptor.getInstance().getConfig().getModeMapSizeThreshold();
+ CommonDescriptor.getInstance().getConfig().getModeMapSizeThreshold();
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(GroupedModeAccumulator.class);
private final TSDataType seriesDataType;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedSumAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedSumAccumulator.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedSumAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedSumAccumulator.java
index 0c0325ebd0b30..5c7673d7c7502 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedSumAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedSumAccumulator.java
@@ -16,11 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BooleanBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BooleanBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedUserDefinedAggregateAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedUserDefinedAggregateAccumulator.java
similarity index 90%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedUserDefinedAggregateAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedUserDefinedAggregateAccumulator.java
index 9ac6b48db7cc4..4b2d13b4adcc3 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedUserDefinedAggregateAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedUserDefinedAggregateAccumulator.java
@@ -17,12 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.MaskedRecordIterator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.RecordIterator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.ObjectBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.MaskedRecordIterator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.RecordIterator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.ObjectBigArray;
import org.apache.iotdb.udf.api.State;
import org.apache.iotdb.udf.api.relational.AggregateFunction;
import org.apache.iotdb.udf.api.utils.ResultValue;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedVarianceAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedVarianceAccumulator.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedVarianceAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedVarianceAccumulator.java
index cb6123b636f33..75446b2cfab11 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedVarianceAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/GroupedVarianceAccumulator.java
@@ -17,12 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.queryengine.execution.aggregation.VarianceAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
+import org.apache.iotdb.calc.execution.aggregation.VarianceAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.DoubleBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.LongBigArray;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.block.column.ColumnBuilder;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/HashAggregationOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/HashAggregationOperator.java
similarity index 82%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/HashAggregationOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/HashAggregationOperator.java
index ce7e91f84485a..997afd10f707d 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/HashAggregationOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/HashAggregationOperator.java
@@ -17,16 +17,16 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.AbstractOperator;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.builder.HashAggregationBuilder;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.builder.InMemoryHashAggregationBuilder;
-import org.apache.iotdb.db.queryengine.plan.planner.memory.MemoryReservationManager;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.node.AggregationNode;
+import org.apache.iotdb.calc.execution.operator.AbstractOperator;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.builder.HashAggregationBuilder;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.builder.InMemoryHashAggregationBuilder;
+import org.apache.iotdb.calc.plan.planner.memory.MemoryReservationManager;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.AggregationNode;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture;
@@ -38,8 +38,8 @@
import java.util.Optional;
import static com.google.common.base.Preconditions.checkState;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.UpdateMemory.NOOP;
-import static org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanGraphPrinter.CURRENT_USED_MEMORY;
+import static org.apache.iotdb.calc.plan.planner.CommonOperatorUtils.CURRENT_USED_MEMORY;
+import static org.apache.iotdb.commons.queryengine.execution.operator.source.relational.aggregation.grouped.UpdateMemory.NOOP;
public class HashAggregationOperator extends AbstractOperator {
private static final long INSTANCE_SIZE =
@@ -69,7 +69,7 @@ public class HashAggregationOperator extends AbstractOperator {
private boolean finished = false;
public HashAggregationOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator child,
List groupByTypes,
List groupByChannels,
@@ -89,11 +89,7 @@ public HashAggregationOperator(
this.maxPartialMemory = maxPartialMemory;
this.spillEnabled = spillEnabled;
this.unspillMemoryLimit = unspillMemoryLimit;
- this.memoryReservationManager =
- operatorContext
- .getDriverContext()
- .getFragmentInstanceContext()
- .getMemoryReservationContext();
+ this.memoryReservationManager = operatorContext.getMemoryReservationContext();
}
@Override
@@ -199,7 +195,7 @@ public void close() throws Exception {
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/IntGroupedApproxMostFrequentAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/IntGroupedApproxMostFrequentAccumulator.java
similarity index 84%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/IntGroupedApproxMostFrequentAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/IntGroupedApproxMostFrequentAccumulator.java
index 42ea037aecf9e..243c9704a08b8 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/IntGroupedApproxMostFrequentAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/IntGroupedApproxMostFrequentAccumulator.java
@@ -12,13 +12,13 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.IntApproxMostFrequentAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.SpaceSavingBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.IntApproxMostFrequentAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.SpaceSavingBigArray;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/LongGroupedApproxMostFrequentAccumulator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/LongGroupedApproxMostFrequentAccumulator.java
similarity index 84%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/LongGroupedApproxMostFrequentAccumulator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/LongGroupedApproxMostFrequentAccumulator.java
index 2e2d3dfb3c6ea..50899d0d25172 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/LongGroupedApproxMostFrequentAccumulator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/LongGroupedApproxMostFrequentAccumulator.java
@@ -12,13 +12,13 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.AggregationMask;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.LongApproxMostFrequentAccumulator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.SpaceSavingBigArray;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationMask;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.LongApproxMostFrequentAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.SpaceSavingBigArray;
+import org.apache.iotdb.commons.exception.SemanticException;
import org.apache.tsfile.block.column.Column;
import org.apache.tsfile.utils.RamUsageEstimator;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/StreamingAggregationOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/StreamingAggregationOperator.java
similarity index 90%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/StreamingAggregationOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/StreamingAggregationOperator.java
index 6f151ceef22b2..7609ac32926a4 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/StreamingAggregationOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/StreamingAggregationOperator.java
@@ -17,16 +17,16 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.AbstractOperator;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.AbstractTableScanOperator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.TableAggregator;
-import org.apache.iotdb.db.queryengine.plan.relational.type.InternalTypeManager;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
+import org.apache.iotdb.calc.execution.operator.AbstractOperator;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.TableAggregator;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
+import org.apache.iotdb.commons.queryengine.plan.relational.type.InternalTypeManager;
import com.google.common.primitives.Ints;
import com.google.common.util.concurrent.ListenableFuture;
@@ -74,7 +74,7 @@ public class StreamingAggregationOperator extends AbstractOperator {
private final Deque outputs = new LinkedList<>();
public StreamingAggregationOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator child,
List groupByTypes,
List groupByChannels,
@@ -206,8 +206,7 @@ private void evaluateAndFlushGroup(TsBlock page, int position, boolean lastCalcu
outputs.add(
resultBuilder.build(
new RunLengthEncodedColumn(
- AbstractTableScanOperator.TIME_COLUMN_TEMPLATE,
- resultBuilder.getPositionCount())));
+ CommonOperatorUtils.TIME_COLUMN_TEMPLATE, resultBuilder.getPositionCount())));
resultBuilder.reset();
}
@@ -257,7 +256,7 @@ public void close() throws Exception {
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/StreamingHashAggregationOperator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/StreamingHashAggregationOperator.java
similarity index 88%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/StreamingHashAggregationOperator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/StreamingHashAggregationOperator.java
index ee58c827e4640..49c41bf7fa30f 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/StreamingHashAggregationOperator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/StreamingHashAggregationOperator.java
@@ -17,17 +17,17 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped;
-
-import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
-import org.apache.iotdb.db.queryengine.execution.operator.AbstractOperator;
-import org.apache.iotdb.db.queryengine.execution.operator.Operator;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.builder.HashAggregationBuilder;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.builder.InMemoryHashAggregationBuilder;
-import org.apache.iotdb.db.queryengine.plan.planner.memory.MemoryReservationManager;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.node.AggregationNode;
-import org.apache.iotdb.db.utils.datastructure.SortKey;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped;
+
+import org.apache.iotdb.calc.execution.operator.AbstractOperator;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.builder.HashAggregationBuilder;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.builder.InMemoryHashAggregationBuilder;
+import org.apache.iotdb.calc.plan.planner.memory.MemoryReservationManager;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
+import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.AggregationNode;
import com.google.common.primitives.Ints;
import com.google.common.util.concurrent.ListenableFuture;
@@ -45,9 +45,9 @@
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.UpdateMemory.NOOP;
-import static org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanGraphPrinter.CURRENT_USED_MEMORY;
-import static org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanGraphPrinter.MAX_USED_MEMORY;
+import static org.apache.iotdb.calc.plan.planner.CommonOperatorUtils.CURRENT_USED_MEMORY;
+import static org.apache.iotdb.calc.plan.planner.CommonOperatorUtils.MAX_USED_MEMORY;
+import static org.apache.iotdb.commons.queryengine.execution.operator.source.relational.aggregation.grouped.UpdateMemory.NOOP;
public class StreamingHashAggregationOperator extends AbstractOperator {
private static final long INSTANCE_SIZE =
@@ -87,7 +87,7 @@ public class StreamingHashAggregationOperator extends AbstractOperator {
private long maxUsedMemory;
public StreamingHashAggregationOperator(
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
Operator child,
List preGroupedChannels,
List preGroupedIndexInResult,
@@ -127,11 +127,7 @@ public StreamingHashAggregationOperator(
operatorContext,
maxPartialMemory,
NOOP);
- this.memoryReservationManager =
- operatorContext
- .getDriverContext()
- .getFragmentInstanceContext()
- .getMemoryReservationContext();
+ this.memoryReservationManager = operatorContext.getMemoryReservationContext();
updateOccupiedMemorySize();
}
@@ -327,7 +323,7 @@ public void close() throws Exception {
}
@Override
- public OperatorContext getOperatorContext() {
+ public CommonOperatorContext getOperatorContext() {
return operatorContext;
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/BigArrays.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/BigArrays.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/BigArrays.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/BigArrays.java
index ffc84077341fa..b86a8dae1840f 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/BigArrays.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/BigArrays.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array;
// Note: this code was forked from fastutil (http://fastutil.di.unimi.it/)
// Copyright (C) 2010-2013 Sebastiano Vigna
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/BinaryBigArray.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/BinaryBigArray.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/BinaryBigArray.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/BinaryBigArray.java
index f008e704618c0..3996b19725431 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/BinaryBigArray.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/BinaryBigArray.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array;
import org.apache.tsfile.utils.Binary;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/BooleanBigArray.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/BooleanBigArray.java
similarity index 89%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/BooleanBigArray.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/BooleanBigArray.java
index 9439cf84020b6..267b918fad5e9 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/BooleanBigArray.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/BooleanBigArray.java
@@ -17,14 +17,14 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array;
import java.util.Arrays;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.INITIAL_SEGMENTS;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SIZE;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.offset;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.segment;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.INITIAL_SEGMENTS;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SIZE;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.offset;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.segment;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOf;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOfInstance;
import static org.apache.tsfile.utils.RamUsageEstimator.sizeOfBooleanArray;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/ByteBigArray.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/ByteBigArray.java
similarity index 89%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/ByteBigArray.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/ByteBigArray.java
index aeea9f985e698..321bca3c4b5ee 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/ByteBigArray.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/ByteBigArray.java
@@ -17,14 +17,14 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array;
import java.util.Arrays;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.INITIAL_SEGMENTS;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SIZE;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.offset;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.segment;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.INITIAL_SEGMENTS;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SIZE;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.offset;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.segment;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOf;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOfInstance;
import static org.apache.tsfile.utils.RamUsageEstimator.sizeOfByteArray;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/DoubleBigArray.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/DoubleBigArray.java
similarity index 89%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/DoubleBigArray.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/DoubleBigArray.java
index df6b42005543c..492774879a8b7 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/DoubleBigArray.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/DoubleBigArray.java
@@ -17,14 +17,14 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array;
import java.util.Arrays;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.INITIAL_SEGMENTS;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SIZE;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.offset;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.segment;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.INITIAL_SEGMENTS;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SIZE;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.offset;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.segment;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOf;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOfInstance;
import static org.apache.tsfile.utils.RamUsageEstimator.sizeOfDoubleArray;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/FloatBigArray.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/FloatBigArray.java
similarity index 89%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/FloatBigArray.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/FloatBigArray.java
index e10c1a26710cc..d8597140c179e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/FloatBigArray.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/FloatBigArray.java
@@ -17,14 +17,14 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array;
import java.util.Arrays;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.INITIAL_SEGMENTS;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SIZE;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.offset;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.segment;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.INITIAL_SEGMENTS;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SIZE;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.offset;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.segment;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOf;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOfInstance;
import static org.apache.tsfile.utils.RamUsageEstimator.sizeOfFloatArray;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/HyperLogLogBigArray.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/HyperLogLogBigArray.java
similarity index 91%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/HyperLogLogBigArray.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/HyperLogLogBigArray.java
index eeca4f849ee99..7d6b3e4c6ec94 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/HyperLogLogBigArray.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/HyperLogLogBigArray.java
@@ -12,9 +12,9 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.HyperLogLog;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.HyperLogLog;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOf;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOfInstance;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/IntArrayFIFOQueue.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/IntArrayFIFOQueue.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/IntArrayFIFOQueue.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/IntArrayFIFOQueue.java
index b80b33ccde37e..94eca74cbdc22 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/IntArrayFIFOQueue.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/IntArrayFIFOQueue.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array;
import java.io.IOException;
import java.io.ObjectInputStream;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/IntBigArray.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/IntBigArray.java
similarity index 90%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/IntBigArray.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/IntBigArray.java
index e124612b721ce..236bd7d55a02f 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/IntBigArray.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/IntBigArray.java
@@ -17,14 +17,14 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array;
import java.util.Arrays;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.INITIAL_SEGMENTS;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SIZE;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.offset;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.segment;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.INITIAL_SEGMENTS;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SIZE;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.offset;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.segment;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOf;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOfInstance;
import static org.apache.tsfile.utils.RamUsageEstimator.sizeOfIntArray;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/IntBigArrays.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/IntBigArrays.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/IntBigArrays.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/IntBigArrays.java
index fbc2a4f185276..c68341c8c77a1 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/IntBigArrays.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/IntBigArrays.java
@@ -17,10 +17,10 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SHIFT;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SIZE;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SHIFT;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SIZE;
// Note: this code was forked from fastutil (http://fastutil.di.unimi.it/)
// Copyright (C) 2010-2013 Sebastiano Vigna
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/IntComparator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/IntComparator.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/IntComparator.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/IntComparator.java
index e562d49b0ed6a..d45b5e2c8098a 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/IntComparator.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/IntComparator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array;
// Note: this code was forked from fastutil (http://fastutil.di.unimi.it/)
// Copyright (C) 2010-2013 Sebastiano Vigna
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/LongBigArray.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/LongBigArray.java
similarity index 90%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/LongBigArray.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/LongBigArray.java
index 5f35525d1e4af..7a65b49218b3d 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/LongBigArray.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/LongBigArray.java
@@ -17,14 +17,14 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array;
import java.util.Arrays;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.INITIAL_SEGMENTS;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SIZE;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.offset;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.segment;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.INITIAL_SEGMENTS;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SIZE;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.offset;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.segment;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOf;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOfInstance;
import static org.apache.tsfile.utils.RamUsageEstimator.sizeOfLongArray;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/LongBigArrayFIFOQueue.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/LongBigArrayFIFOQueue.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/LongBigArrayFIFOQueue.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/LongBigArrayFIFOQueue.java
index 24c25dfb62c63..a9232024ef55c 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/LongBigArrayFIFOQueue.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/LongBigArrayFIFOQueue.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array;
import java.util.NoSuchElementException;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/MapBigArray.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/MapBigArray.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/MapBigArray.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/MapBigArray.java
index 1be73705b31a3..f6e4c8d750bc4 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/MapBigArray.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/MapBigArray.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array;
import org.apache.tsfile.utils.TsPrimitiveType;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/ObjectBigArray.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/ObjectBigArray.java
similarity index 90%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/ObjectBigArray.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/ObjectBigArray.java
index b5585824e431d..0c5330b5a614b 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/ObjectBigArray.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/ObjectBigArray.java
@@ -17,15 +17,15 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array;
import java.util.Arrays;
import java.util.function.Consumer;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.INITIAL_SEGMENTS;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SIZE;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.offset;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.segment;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.INITIAL_SEGMENTS;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SIZE;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.offset;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.segment;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOf;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOfInstance;
import static org.apache.tsfile.utils.RamUsageEstimator.sizeOfObjectArray;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/ShortBigArray.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/ShortBigArray.java
similarity index 90%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/ShortBigArray.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/ShortBigArray.java
index 38bdb76b7331d..ce4b5bb69b8b9 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/ShortBigArray.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/ShortBigArray.java
@@ -17,16 +17,16 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array;
import com.google.common.primitives.Shorts;
import java.util.Arrays;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.INITIAL_SEGMENTS;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SIZE;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.offset;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array.BigArrays.segment;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.INITIAL_SEGMENTS;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.SEGMENT_SIZE;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.offset;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array.BigArrays.segment;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOf;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOfInstance;
import static org.apache.tsfile.utils.RamUsageEstimator.sizeOfShortArray;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/SpaceSavingBigArray.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/SpaceSavingBigArray.java
similarity index 80%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/SpaceSavingBigArray.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/SpaceSavingBigArray.java
index 1c120271d95ea..959398873e6b4 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/SpaceSavingBigArray.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/SpaceSavingBigArray.java
@@ -12,12 +12,12 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.ApproxMostFrequentBucketDeserializer;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.ApproxMostFrequentBucketSerializer;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.SpaceSavingByteCalculator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.ApproxMostFrequentBucketDeserializer;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.ApproxMostFrequentBucketSerializer;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSaving;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.SpaceSavingByteCalculator;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOf;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOfInstance;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/TDigestBigArray.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/TDigestBigArray.java
similarity index 90%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/TDigestBigArray.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/TDigestBigArray.java
index 81ab7cf92141a..06eab4e57e1d8 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/TDigestBigArray.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/array/TDigestBigArray.java
@@ -12,9 +12,9 @@
* limitations under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.array;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.array;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.approximate.TDigest;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.approximate.TDigest;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOf;
import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOfInstance;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/builder/HashAggregationBuilder.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/builder/HashAggregationBuilder.java
similarity index 91%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/builder/HashAggregationBuilder.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/builder/HashAggregationBuilder.java
index 0fc8ab0a4d9b3..660ed74adb685 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/builder/HashAggregationBuilder.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/builder/HashAggregationBuilder.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.builder;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.builder;
import org.apache.tsfile.read.common.block.TsBlock;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/builder/InMemoryHashAggregationBuilder.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/builder/InMemoryHashAggregationBuilder.java
similarity index 87%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/builder/InMemoryHashAggregationBuilder.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/builder/InMemoryHashAggregationBuilder.java
index 3103055023b0e..f372717a92fab 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/builder/InMemoryHashAggregationBuilder.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/builder/InMemoryHashAggregationBuilder.java
@@ -17,15 +17,15 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.builder;
+package org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.builder;
-import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.GroupedAggregator;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.UpdateMemory;
-import org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.hash.GroupByHash;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.node.AggregationNode;
-import org.apache.iotdb.db.queryengine.plan.relational.type.InternalTypeManager;
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedAggregator;
+import org.apache.iotdb.calc.plan.planner.CommonOperatorUtils;
+import org.apache.iotdb.commons.queryengine.execution.operator.source.relational.aggregation.grouped.UpdateMemory;
+import org.apache.iotdb.commons.queryengine.execution.operator.source.relational.aggregation.grouped.hash.GroupByHash;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.AggregationNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.type.InternalTypeManager;
import com.google.common.collect.ImmutableList;
import com.google.common.primitives.Ints;
@@ -47,7 +47,7 @@
import java.util.stream.IntStream;
import java.util.stream.Stream;
-import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.aggregation.grouped.hash.GroupByHash.createGroupByHash;
+import static org.apache.iotdb.commons.queryengine.execution.operator.source.relational.aggregation.grouped.hash.GroupByHash.createGroupByHash;
public class InMemoryHashAggregationBuilder implements HashAggregationBuilder {
private final int[] groupByChannels;
@@ -66,7 +66,7 @@ public class InMemoryHashAggregationBuilder implements HashAggregationBuilder {
private final int expectedGroups;
private final Optional hashChannel;
- private final OperatorContext operatorContext;
+ private final CommonOperatorContext operatorContext;
private static final String CURRENT_GROUP_NUMBER = "CurrentGroupNumber";
private static final String MAX_GROUP_NUMBER = "MaxGroupNumber";
@@ -79,7 +79,7 @@ public InMemoryHashAggregationBuilder(
List groupByTypes,
List groupByChannels,
Optional hashChannel,
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
long maxPartialMemory,
UpdateMemory updateMemory) {
this(
@@ -102,7 +102,7 @@ public InMemoryHashAggregationBuilder(
List groupByTypes,
List groupByChannels,
Optional hashChannel,
- OperatorContext operatorContext,
+ CommonOperatorContext operatorContext,
long maxPartialMemory,
Optional unspillIntermediateChannelOffset,
UpdateMemory updateMemory) {
@@ -252,7 +252,7 @@ private TsBlock buildResult(Iterator groupIds) {
return TsBlock.wrapBlocksWithoutCopy(
pageBuilder.getPositionCount(),
new RunLengthEncodedColumn(
- TableScanOperator.TIME_COLUMN_TEMPLATE, pageBuilder.getPositionCount()),
+ CommonOperatorUtils.TIME_COLUMN_TEMPLATE, pageBuilder.getPositionCount()),
Arrays.stream(pageBuilder.getValueColumnBuilders())
.map(ColumnBuilder::build)
.toArray(Column[]::new));
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/relational/ColumnTransformerBuilder.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/relational/ColumnTransformerBuilder.java
similarity index 77%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/relational/ColumnTransformerBuilder.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/relational/ColumnTransformerBuilder.java
index cf416a184a9ce..42f8f8bed59dc 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/relational/ColumnTransformerBuilder.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/relational/ColumnTransformerBuilder.java
@@ -17,186 +17,185 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.execution.relational;
-
+package org.apache.iotdb.calc.execution.relational;
+
+import org.apache.iotdb.calc.plan.relational.metadata.ITypeMetadata;
+import org.apache.iotdb.calc.transformation.dag.column.ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.FailFunctionColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.TableCaseWhenThenColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.binary.ArithmeticColumnTransformerApi;
+import org.apache.iotdb.calc.transformation.dag.column.binary.CompareEqualToColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.binary.CompareGreaterEqualColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.binary.CompareGreaterThanColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.binary.CompareLessEqualColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.binary.CompareLessThanColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.binary.CompareNonEqualColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.binary.HmacColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.binary.Like2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.binary.factory.HmacStrategiesFactory;
+import org.apache.iotdb.calc.transformation.dag.column.leaf.ConstantColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.leaf.IdentityColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.leaf.LeafColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.leaf.NullColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.leaf.TimeColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.multi.AbstractGreatestLeastColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.multi.CoalesceColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.multi.InBinaryMultiColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.multi.InBooleanMultiColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.multi.InDoubleMultiColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.multi.InFloatMultiColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.multi.InInt32MultiColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.multi.InInt64MultiColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.multi.InMultiColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.multi.LogicalAndMultiColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.multi.LogicalOrMultiColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.ternary.BetweenColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.ternary.Like3ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.ternary.LpadColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.ternary.RpadColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.udf.UserDefineScalarFunctionTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.IsNullColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.LikeColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.LogicNotColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.AbsColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.AcosColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.AsinColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.AtanColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BitCount2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BitCountColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BitwiseAnd2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BitwiseAndColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BitwiseLeftShift2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BitwiseLeftShiftColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BitwiseNotColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BitwiseOr2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BitwiseOrColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BitwiseRightShift2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BitwiseRightShiftArithmetic2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BitwiseRightShiftArithmeticColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BitwiseRightShiftColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BitwiseXor2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BitwiseXorColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BlobLengthColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BytesToDoubleColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BytesToFloatColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BytesToIntColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.BytesToLongColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.CRC32Transformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.CastFunctionColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.CeilColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.Concat2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.ConcatColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.ConcatMultiColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.CosColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.CoshColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.DateBinFunctionColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.DegreesColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.DiffColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.DiffFunctionColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.DoubleToBytesColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.EndsWith2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.EndsWithColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.ExpColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.ExtractTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.FloatToBytesColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.FloorColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.FormatColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.GenericCodecColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.HmacConstantKeyColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.IntToBytesColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.LTrim2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.LTrimColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.LengthColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.LnColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.Log10ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.LongToBytesColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.LowerColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.ObjectLengthColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.RTrim2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.RTrimColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.RadiansColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.RegexpLike2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.RegexpLikeColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.Replace2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.Replace3ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.ReplaceFunctionColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.RoundColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.RoundFunctionColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.SignColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.SinColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.SinhColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.SqrtColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.StartsWith2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.StartsWithColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.Strcmp2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.StrcmpColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.Strpos2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.StrposColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.SubString2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.SubString3ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.SubStringColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.TanColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.TanhColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.Trim2ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.TrimColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.TryCastFunctionColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.UpperColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.factory.CodecStrategiesFactory;
+import org.apache.iotdb.calc.transformation.dag.column.unary.scalar.factory.NumericCodecStrategiesFactory;
+import org.apache.iotdb.commons.conf.CommonDescriptor;
+import org.apache.iotdb.commons.exception.SemanticException;
+import org.apache.iotdb.commons.queryengine.common.SessionInfo;
+import org.apache.iotdb.commons.queryengine.plan.analyze.ITableTypeProvider;
+import org.apache.iotdb.commons.queryengine.plan.planner.plan.parameter.InputLocation;
+import org.apache.iotdb.commons.queryengine.plan.relational.function.arithmetic.AdditionResolver;
+import org.apache.iotdb.commons.queryengine.plan.relational.function.arithmetic.DivisionResolver;
+import org.apache.iotdb.commons.queryengine.plan.relational.function.arithmetic.ModulusResolver;
+import org.apache.iotdb.commons.queryengine.plan.relational.function.arithmetic.MultiplicationResolver;
+import org.apache.iotdb.commons.queryengine.plan.relational.function.arithmetic.SubtractionResolver;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.Symbol;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.ArithmeticBinaryExpression;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.ArithmeticUnaryExpression;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.BetweenPredicate;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.BinaryLiteral;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.BooleanLiteral;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.Cast;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.CoalesceExpression;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.CommonQueryAstVisitor;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.ComparisonExpression;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.CurrentDatabase;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.CurrentTime;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.CurrentUser;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.DecimalLiteral;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.DoubleLiteral;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.Expression;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.Extract;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.FloatLiteral;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.FunctionCall;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.GenericLiteral;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.IfExpression;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.InListExpression;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.InPredicate;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.IsNotNullPredicate;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.IsNullPredicate;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.LikePredicate;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.Literal;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.LogicalExpression;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.LongLiteral;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.NotExpression;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.NullIfExpression;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.NullLiteral;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.SearchedCaseExpression;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.SimpleCaseExpression;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.StringLiteral;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.SymbolReference;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.Trim;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.WhenClause;
+import org.apache.iotdb.commons.queryengine.plan.relational.type.InternalTypeManager;
+import org.apache.iotdb.commons.queryengine.plan.relational.type.TypeNotFoundException;
+import org.apache.iotdb.commons.queryengine.plan.udf.TableUDFUtils;
import org.apache.iotdb.commons.udf.builtin.relational.TableBuiltinScalarFunction;
import org.apache.iotdb.commons.udf.utils.UDFDataTypeTransformer;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.queryengine.common.SessionInfo;
-import org.apache.iotdb.db.queryengine.execution.fragment.FragmentInstanceContext;
-import org.apache.iotdb.db.queryengine.plan.analyze.TypeProvider;
-import org.apache.iotdb.db.queryengine.plan.planner.plan.parameter.InputLocation;
-import org.apache.iotdb.db.queryengine.plan.relational.function.arithmetic.AdditionResolver;
-import org.apache.iotdb.db.queryengine.plan.relational.function.arithmetic.DivisionResolver;
-import org.apache.iotdb.db.queryengine.plan.relational.function.arithmetic.ModulusResolver;
-import org.apache.iotdb.db.queryengine.plan.relational.function.arithmetic.MultiplicationResolver;
-import org.apache.iotdb.db.queryengine.plan.relational.function.arithmetic.SubtractionResolver;
-import org.apache.iotdb.db.queryengine.plan.relational.metadata.Metadata;
-import org.apache.iotdb.db.queryengine.plan.relational.planner.Symbol;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ArithmeticBinaryExpression;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ArithmeticUnaryExpression;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.AstVisitor;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.BetweenPredicate;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.BinaryLiteral;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.BooleanLiteral;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Cast;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CoalesceExpression;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ComparisonExpression;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CurrentDatabase;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CurrentTime;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CurrentUser;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.DecimalLiteral;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.DoubleLiteral;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Expression;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Extract;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.FloatLiteral;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.FunctionCall;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.GenericLiteral;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.IfExpression;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.InListExpression;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.InPredicate;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.IsNotNullPredicate;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.IsNullPredicate;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.LikePredicate;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Literal;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.LogicalExpression;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.LongLiteral;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.NotExpression;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.NullIfExpression;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.NullLiteral;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SearchedCaseExpression;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SimpleCaseExpression;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.StringLiteral;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SymbolReference;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Trim;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.WhenClause;
-import org.apache.iotdb.db.queryengine.plan.relational.type.InternalTypeManager;
-import org.apache.iotdb.db.queryengine.plan.relational.type.TypeNotFoundException;
-import org.apache.iotdb.db.queryengine.plan.udf.TableUDFUtils;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.FailFunctionColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.TableCaseWhenThenColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.binary.ArithmeticColumnTransformerApi;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.binary.CompareEqualToColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.binary.CompareGreaterEqualColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.binary.CompareGreaterThanColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.binary.CompareLessEqualColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.binary.CompareLessThanColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.binary.CompareNonEqualColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.binary.HmacColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.binary.Like2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.binary.factory.HmacStrategiesFactory;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.leaf.ConstantColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.leaf.IdentityColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.leaf.LeafColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.leaf.NullColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.leaf.TimeColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.multi.AbstractGreatestLeastColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.multi.CoalesceColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.multi.InBinaryMultiColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.multi.InBooleanMultiColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.multi.InDoubleMultiColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.multi.InFloatMultiColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.multi.InInt32MultiColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.multi.InInt64MultiColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.multi.InMultiColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.multi.LogicalAndMultiColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.multi.LogicalOrMultiColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.ternary.BetweenColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.ternary.Like3ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.ternary.LpadColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.ternary.RpadColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.udf.UserDefineScalarFunctionTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.IsNullColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.LikeColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.LogicNotColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.AbsColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.AcosColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.AsinColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.AtanColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BitCount2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BitCountColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BitwiseAnd2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BitwiseAndColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BitwiseLeftShift2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BitwiseLeftShiftColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BitwiseNotColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BitwiseOr2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BitwiseOrColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BitwiseRightShift2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BitwiseRightShiftArithmetic2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BitwiseRightShiftArithmeticColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BitwiseRightShiftColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BitwiseXor2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BitwiseXorColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BlobLengthColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BytesToDoubleColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BytesToFloatColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BytesToIntColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.BytesToLongColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.CRC32Transformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.CastFunctionColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.CeilColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.Concat2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.ConcatColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.ConcatMultiColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.CosColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.CoshColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.DateBinFunctionColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.DegreesColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.DiffColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.DiffFunctionColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.DoubleToBytesColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.EndsWith2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.EndsWithColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.ExpColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.ExtractTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.FloatToBytesColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.FloorColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.FormatColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.GenericCodecColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.HmacConstantKeyColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.IntToBytesColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.LTrim2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.LTrimColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.LengthColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.LnColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.Log10ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.LongToBytesColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.LowerColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.ObjectLengthColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.RTrim2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.RTrimColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.RadiansColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.RegexpLike2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.RegexpLikeColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.Replace2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.Replace3ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.ReplaceFunctionColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.RoundColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.RoundFunctionColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.SignColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.SinColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.SinhColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.SqrtColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.StartsWith2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.StartsWithColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.Strcmp2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.StrcmpColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.Strpos2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.StrposColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.SubString2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.SubString3ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.SubStringColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.TanColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.TanhColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.Trim2ColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.TrimColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.TryCastFunctionColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.UpperColumnTransformer;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.factory.CodecStrategiesFactory;
-import org.apache.iotdb.db.queryengine.transformation.dag.column.unary.scalar.factory.NumericCodecStrategiesFactory;
import org.apache.iotdb.udf.api.customizer.analysis.ScalarFunctionAnalysis;
import org.apache.iotdb.udf.api.customizer.parameter.FunctionArguments;
import org.apache.iotdb.udf.api.relational.ScalarFunction;
@@ -216,8 +215,6 @@
import org.apache.tsfile.read.common.type.TypeEnum;
import org.apache.tsfile.utils.Binary;
-import javax.annotation.Nullable;
-
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Arrays;
@@ -230,17 +227,17 @@
import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkArgument;
-import static org.apache.iotdb.db.queryengine.plan.expression.unary.LikeExpression.getEscapeCharacter;
-import static org.apache.iotdb.db.queryengine.plan.relational.analyzer.predicate.PredicatePushIntoMetadataChecker.isStringLiteral;
-import static org.apache.iotdb.db.queryengine.plan.relational.metadata.TableMetadataImpl.isBlobType;
-import static org.apache.iotdb.db.queryengine.plan.relational.metadata.TableMetadataImpl.isCharType;
-import static org.apache.iotdb.db.queryengine.plan.relational.type.InternalTypeManager.getTSDataType;
-import static org.apache.iotdb.db.queryengine.plan.relational.type.TypeSignatureTranslator.toTypeSignature;
-import static org.apache.iotdb.db.queryengine.transformation.dag.column.FailFunctionColumnTransformer.FAIL_FUNCTION_NAME;
-import static org.apache.iotdb.db.queryengine.transformation.dag.column.binary.factory.HmacStrategiesFactory.createConstantKeyHmacMd5Strategy;
-import static org.apache.iotdb.db.queryengine.transformation.dag.column.binary.factory.HmacStrategiesFactory.createConstantKeyHmacSha1Strategy;
-import static org.apache.iotdb.db.queryengine.transformation.dag.column.binary.factory.HmacStrategiesFactory.createConstantKeyHmacSha256Strategy;
-import static org.apache.iotdb.db.queryengine.transformation.dag.column.binary.factory.HmacStrategiesFactory.createConstantKeyHmacSha512Strategy;
+import static org.apache.iotdb.calc.plan.relational.metadata.CommonMetadataUtils.isBlobType;
+import static org.apache.iotdb.calc.plan.relational.metadata.CommonMetadataUtils.isCharType;
+import static org.apache.iotdb.calc.transformation.dag.column.FailFunctionColumnTransformer.FAIL_FUNCTION_NAME;
+import static org.apache.iotdb.calc.transformation.dag.column.binary.factory.HmacStrategiesFactory.createConstantKeyHmacMd5Strategy;
+import static org.apache.iotdb.calc.transformation.dag.column.binary.factory.HmacStrategiesFactory.createConstantKeyHmacSha1Strategy;
+import static org.apache.iotdb.calc.transformation.dag.column.binary.factory.HmacStrategiesFactory.createConstantKeyHmacSha256Strategy;
+import static org.apache.iotdb.calc.transformation.dag.column.binary.factory.HmacStrategiesFactory.createConstantKeyHmacSha512Strategy;
+import static org.apache.iotdb.calc.transformation.dag.util.CommonTransformUtils.getEscapeCharacter;
+import static org.apache.iotdb.calc.transformation.dag.util.CommonTransformUtils.isStringLiteral;
+import static org.apache.iotdb.commons.queryengine.plan.relational.type.InternalTypeManager.getTSDataType;
+import static org.apache.iotdb.commons.queryengine.plan.relational.type.TypeSignatureTranslator.toTypeSignature;
import static org.apache.tsfile.read.common.type.BlobType.BLOB;
import static org.apache.tsfile.read.common.type.BooleanType.BOOLEAN;
import static org.apache.tsfile.read.common.type.DoubleType.DOUBLE;
@@ -250,7 +247,7 @@
import static org.apache.tsfile.read.common.type.StringType.STRING;
public class ColumnTransformerBuilder
- extends AstVisitor {
+ implements CommonQueryAstVisitor {
private static final String UNSUPPORTED_EXPRESSION = "Unsupported expression: %s";
@@ -261,8 +258,7 @@ public ColumnTransformer visitExpression(Expression expression, Context context)
}
@Override
- protected ColumnTransformer visitArithmeticBinary(
- ArithmeticBinaryExpression node, Context context) {
+ public ColumnTransformer visitArithmeticBinary(ArithmeticBinaryExpression node, Context context) {
if (!context.cache.containsKey(node)) {
if (context.hasSeen.containsKey(node)) {
ColumnTransformer left = process(node.getLeft(), context);
@@ -324,8 +320,7 @@ protected ColumnTransformer visitArithmeticBinary(
}
@Override
- protected ColumnTransformer visitArithmeticUnary(
- ArithmeticUnaryExpression node, Context context) {
+ public ColumnTransformer visitArithmeticUnary(ArithmeticUnaryExpression node, Context context) {
switch (node.getSign()) {
case PLUS:
return process(node.getValue(), context);
@@ -347,7 +342,7 @@ protected ColumnTransformer visitArithmeticUnary(
}
@Override
- protected ColumnTransformer visitBetweenPredicate(BetweenPredicate node, Context context) {
+ public ColumnTransformer visitBetweenPredicate(BetweenPredicate node, Context context) {
if (!context.cache.containsKey(node)) {
if (context.hasSeen.containsKey(node)) {
appendIdentityColumnTransformer(node, BOOLEAN, TSDataType.BOOLEAN, context);
@@ -362,7 +357,7 @@ protected ColumnTransformer visitBetweenPredicate(BetweenPredicate node, Context
}
@Override
- protected ColumnTransformer visitCast(Cast node, Context context) {
+ public ColumnTransformer visitCast(Cast node, Context context) {
if (!context.cache.containsKey(node)) {
if (context.hasSeen.containsKey(node)) {
@@ -392,7 +387,7 @@ protected ColumnTransformer visitCast(Cast node, Context context) {
}
@Override
- protected ColumnTransformer visitExtract(Extract node, Context context) {
+ public ColumnTransformer visitExtract(Extract node, Context context) {
if (!context.cache.containsKey(node)) {
if (context.hasSeen.containsKey(node)) {
ColumnTransformer columnTransformer = context.hasSeen.get(node);
@@ -413,7 +408,7 @@ protected ColumnTransformer visitExtract(Extract node, Context context) {
}
@Override
- protected ColumnTransformer visitBooleanLiteral(BooleanLiteral node, Context context) {
+ public ColumnTransformer visitBooleanLiteral(BooleanLiteral node, Context context) {
ColumnTransformer res =
context.cache.computeIfAbsent(
node,
@@ -430,7 +425,7 @@ protected ColumnTransformer visitBooleanLiteral(BooleanLiteral node, Context con
}
@Override
- protected ColumnTransformer visitBinaryLiteral(BinaryLiteral node, Context context) {
+ public ColumnTransformer visitBinaryLiteral(BinaryLiteral node, Context context) {
ColumnTransformer res =
context.cache.computeIfAbsent(
node,
@@ -448,7 +443,7 @@ protected ColumnTransformer visitBinaryLiteral(BinaryLiteral node, Context conte
}
@Override
- protected ColumnTransformer visitStringLiteral(StringLiteral node, Context context) {
+ public ColumnTransformer visitStringLiteral(StringLiteral node, Context context) {
ColumnTransformer res =
context.cache.computeIfAbsent(
node,
@@ -468,7 +463,7 @@ protected ColumnTransformer visitStringLiteral(StringLiteral node, Context conte
}
@Override
- protected ColumnTransformer visitLongLiteral(LongLiteral node, Context context) {
+ public ColumnTransformer visitLongLiteral(LongLiteral node, Context context) {
ColumnTransformer res =
context.cache.computeIfAbsent(
node,
@@ -495,7 +490,7 @@ protected ColumnTransformer visitLongLiteral(LongLiteral node, Context context)
}
@Override
- protected ColumnTransformer visitDoubleLiteral(DoubleLiteral node, Context context) {
+ public ColumnTransformer visitDoubleLiteral(DoubleLiteral node, Context context) {
ColumnTransformer res =
context.cache.computeIfAbsent(
node,
@@ -512,7 +507,7 @@ protected ColumnTransformer visitDoubleLiteral(DoubleLiteral node, Context conte
}
@Override
- protected ColumnTransformer visitFloatLiteral(FloatLiteral node, Context context) {
+ public ColumnTransformer visitFloatLiteral(FloatLiteral node, Context context) {
ColumnTransformer res =
context.cache.computeIfAbsent(
node,
@@ -528,12 +523,12 @@ protected ColumnTransformer visitFloatLiteral(FloatLiteral node, Context context
}
@Override
- protected ColumnTransformer visitDecimalLiteral(DecimalLiteral node, Context context) {
+ public ColumnTransformer visitDecimalLiteral(DecimalLiteral node, Context context) {
throw new UnsupportedOperationException();
}
@Override
- protected ColumnTransformer visitGenericLiteral(GenericLiteral node, Context context) {
+ public ColumnTransformer visitGenericLiteral(GenericLiteral node, Context context) {
ColumnTransformer res =
context.cache.computeIfAbsent(
node,
@@ -570,7 +565,7 @@ private static ConstantColumnTransformer getColumnTransformerForGenericLiteral(
}
@Override
- protected ColumnTransformer visitNullLiteral(NullLiteral node, Context context) {
+ public ColumnTransformer visitNullLiteral(NullLiteral node, Context context) {
ColumnTransformer res =
context.cache.computeIfAbsent(
node,
@@ -584,8 +579,7 @@ protected ColumnTransformer visitNullLiteral(NullLiteral node, Context context)
}
@Override
- protected ColumnTransformer visitComparisonExpression(
- ComparisonExpression node, Context context) {
+ public ColumnTransformer visitComparisonExpression(ComparisonExpression node, Context context) {
ColumnTransformer comparisonTransformer;
if (context.cache.containsKey(node)) {
comparisonTransformer = context.cache.get(node);
@@ -632,7 +626,7 @@ private ColumnTransformer getColumnTransformer(ComparisonExpression node, Contex
}
@Override
- protected ColumnTransformer visitCurrentDatabase(CurrentDatabase node, Context context) {
+ public ColumnTransformer visitCurrentDatabase(CurrentDatabase node, Context context) {
Optional currentDatabase = context.sessionInfo.getDatabaseName();
ColumnTransformer res;
res =
@@ -666,12 +660,12 @@ protected ColumnTransformer visitCurrentDatabase(CurrentDatabase node, Context c
}
@Override
- protected ColumnTransformer visitCurrentTime(CurrentTime node, Context context) {
+ public ColumnTransformer visitCurrentTime(CurrentTime node, Context context) {
throw new UnsupportedOperationException(String.format(UNSUPPORTED_EXPRESSION, node));
}
@Override
- protected ColumnTransformer visitCurrentUser(CurrentUser node, Context context) {
+ public ColumnTransformer visitCurrentUser(CurrentUser node, Context context) {
String currentUser = context.sessionInfo.getUserName();
ColumnTransformer res =
context.cache.computeIfAbsent(
@@ -692,7 +686,7 @@ protected ColumnTransformer visitCurrentUser(CurrentUser node, Context context)
}
@Override
- protected ColumnTransformer visitFunctionCall(FunctionCall node, Context context) {
+ public ColumnTransformer visitFunctionCall(FunctionCall node, Context context) {
if (!context.cache.containsKey(node)) {
if (context.hasSeen.containsKey(node)) {
ColumnTransformer columnTransformer = context.hasSeen.get(node);
@@ -1499,12 +1493,12 @@ private ColumnTransformer getFunctionColumnTransformer(
}
throw new IllegalArgumentException(
String.format(
- "Unknown function %s on DataNode: %d.",
- functionName, IoTDBDescriptor.getInstance().getConfig().getDataNodeId()));
+ "Unknown function %s on Node: %d.",
+ functionName, CommonDescriptor.getInstance().getConfig().getNodeId()));
}
@Override
- protected ColumnTransformer visitInPredicate(InPredicate node, Context context) {
+ public ColumnTransformer visitInPredicate(InPredicate node, Context context) {
if (!context.cache.containsKey(node)) {
if (context.hasSeen.containsKey(node)) {
appendIdentityColumnTransformer(node, BOOLEAN, TSDataType.BOOLEAN, context);
@@ -1638,7 +1632,7 @@ private static InMultiColumnTransformer constructInColumnTransformer(
}
@Override
- protected ColumnTransformer visitNotExpression(NotExpression node, Context context) {
+ public ColumnTransformer visitNotExpression(NotExpression node, Context context) {
if (!context.cache.containsKey(node)) {
if (context.hasSeen.containsKey(node)) {
appendIdentityColumnTransformer(node, BOOLEAN, TSDataType.BOOLEAN, context);
@@ -1651,7 +1645,7 @@ protected ColumnTransformer visitNotExpression(NotExpression node, Context conte
}
@Override
- protected ColumnTransformer visitLikePredicate(LikePredicate node, Context context) {
+ public ColumnTransformer visitLikePredicate(LikePredicate node, Context context) {
if (!context.cache.containsKey(node)) {
if (context.hasSeen.containsKey(node)) {
appendIdentityColumnTransformer(node, BOOLEAN, TSDataType.BOOLEAN, context);
@@ -1693,7 +1687,7 @@ protected ColumnTransformer visitLikePredicate(LikePredicate node, Context conte
}
@Override
- protected ColumnTransformer visitIsNotNullPredicate(IsNotNullPredicate node, Context context) {
+ public ColumnTransformer visitIsNotNullPredicate(IsNotNullPredicate node, Context context) {
if (!context.cache.containsKey(node)) {
if (context.hasSeen.containsKey(node)) {
appendIdentityColumnTransformer(node, BOOLEAN, TSDataType.BOOLEAN, context);
@@ -1706,7 +1700,7 @@ protected ColumnTransformer visitIsNotNullPredicate(IsNotNullPredicate node, Con
}
@Override
- protected ColumnTransformer visitIsNullPredicate(IsNullPredicate node, Context context) {
+ public ColumnTransformer visitIsNullPredicate(IsNullPredicate node, Context context) {
if (!context.cache.containsKey(node)) {
if (context.hasSeen.containsKey(node)) {
appendIdentityColumnTransformer(node, BOOLEAN, TSDataType.BOOLEAN, context);
@@ -1720,7 +1714,7 @@ protected ColumnTransformer visitIsNullPredicate(IsNullPredicate node, Context c
}
@Override
- protected ColumnTransformer visitLogicalExpression(LogicalExpression node, Context context) {
+ public ColumnTransformer visitLogicalExpression(LogicalExpression node, Context context) {
ColumnTransformer logicalTransformer;
if (context.cache.containsKey(node)) {
logicalTransformer = context.cache.get(node);
@@ -1759,7 +1753,7 @@ private ColumnTransformer getColumnTransformer(LogicalExpression node, Context c
}
@Override
- protected ColumnTransformer visitSymbolReference(SymbolReference node, Context context) {
+ public ColumnTransformer visitSymbolReference(SymbolReference node, Context context) {
ColumnTransformer res =
context.cache.computeIfAbsent(
node,
@@ -1782,7 +1776,7 @@ protected ColumnTransformer visitSymbolReference(SymbolReference node, Context c
}
@Override
- protected ColumnTransformer visitCoalesceExpression(CoalesceExpression node, Context context) {
+ public ColumnTransformer visitCoalesceExpression(CoalesceExpression node, Context context) {
if (!context.cache.containsKey(node)) {
if (context.hasSeen.containsKey(node)) {
ColumnTransformer columnTransformer = context.hasSeen.get(node);
@@ -1804,8 +1798,7 @@ protected ColumnTransformer visitCoalesceExpression(CoalesceExpression node, Con
}
@Override
- protected ColumnTransformer visitSimpleCaseExpression(
- SimpleCaseExpression node, Context context) {
+ public ColumnTransformer visitSimpleCaseExpression(SimpleCaseExpression node, Context context) {
if (!context.cache.containsKey(node)) {
if (context.hasSeen.containsKey(node)) {
ColumnTransformer columnTransformer = context.hasSeen.get(node);
@@ -1841,7 +1834,7 @@ protected ColumnTransformer visitSimpleCaseExpression(
}
@Override
- protected ColumnTransformer visitSearchedCaseExpression(
+ public ColumnTransformer visitSearchedCaseExpression(
SearchedCaseExpression node, Context context) {
if (!context.cache.containsKey(node)) {
if (context.hasSeen.containsKey(node)) {
@@ -1873,17 +1866,17 @@ protected ColumnTransformer visitSearchedCaseExpression(
}
@Override
- protected ColumnTransformer visitTrim(Trim node, Context context) {
+ public ColumnTransformer visitTrim(Trim node, Context context) {
throw new UnsupportedOperationException(String.format(UNSUPPORTED_EXPRESSION, node));
}
@Override
- protected ColumnTransformer visitIfExpression(IfExpression node, Context context) {
+ public ColumnTransformer visitIfExpression(IfExpression node, Context context) {
throw new UnsupportedOperationException(String.format(UNSUPPORTED_EXPRESSION, node));
}
@Override
- protected ColumnTransformer visitNullIfExpression(NullIfExpression node, Context context) {
+ public ColumnTransformer visitNullIfExpression(NullIfExpression node, Context context) {
throw new UnsupportedOperationException(String.format(UNSUPPORTED_EXPRESSION, node));
}
@@ -1947,11 +1940,9 @@ public static class Context {
private final int originSize;
- private final TypeProvider typeProvider;
-
- private final Metadata metadata;
+ private final ITableTypeProvider typeProvider;
- private final Optional fragmentInstanceContext;
+ private final ITypeMetadata metadata;
public Context(
SessionInfo sessionInfo,
@@ -1962,9 +1953,8 @@ public Context(
List commonTransformerList,
List inputDataTypes,
int originSize,
- TypeProvider typeProvider,
- Metadata metadata,
- @Nullable FragmentInstanceContext fragmentInstanceContext) {
+ ITableTypeProvider typeProvider,
+ ITypeMetadata metadata) {
this.sessionInfo = sessionInfo;
this.leafList = leafList;
this.inputLocations = inputLocations;
@@ -1975,7 +1965,6 @@ public Context(
this.originSize = originSize;
this.typeProvider = typeProvider;
this.metadata = metadata;
- this.fragmentInstanceContext = Optional.ofNullable(fragmentInstanceContext);
}
public Type getType(SymbolReference symbolReference) {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/metric/QueryExecutionMetricSet.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/metric/QueryExecutionMetricSet.java
similarity index 99%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/metric/QueryExecutionMetricSet.java
rename to iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/metric/QueryExecutionMetricSet.java
index 27a238d3d8cc0..636b11b4cc02d 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/metric/QueryExecutionMetricSet.java
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/metric/QueryExecutionMetricSet.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.queryengine.metric;
+package org.apache.iotdb.calc.metric;
import org.apache.iotdb.commons.service.metric.enums.Metric;
import org.apache.iotdb.commons.service.metric.enums.Tag;
diff --git a/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/plan/planner/CommonOperatorUtils.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/plan/planner/CommonOperatorUtils.java
new file mode 100644
index 0000000000000..ac29fef3ebe98
--- /dev/null
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/plan/planner/CommonOperatorUtils.java
@@ -0,0 +1,184 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.iotdb.calc.plan.planner;
+
+import org.apache.iotdb.calc.execution.operator.process.fill.IFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.IFillFilter;
+import org.apache.iotdb.calc.execution.operator.process.fill.ILinearFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.filter.FixedIntervalFillFilter;
+import org.apache.iotdb.calc.execution.operator.process.fill.filter.MonthIntervalMSFillFilter;
+import org.apache.iotdb.calc.execution.operator.process.fill.filter.MonthIntervalNSFillFilter;
+import org.apache.iotdb.calc.execution.operator.process.fill.filter.MonthIntervalUSFillFilter;
+import org.apache.iotdb.calc.execution.operator.process.fill.identity.IdentityFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.identity.IdentityLinearFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.linear.DoubleLinearFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.linear.FloatLinearFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.linear.IntLinearFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.linear.LongLinearFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.previous.BinaryPreviousFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.previous.BinaryPreviousFillWithTimeDuration;
+import org.apache.iotdb.calc.execution.operator.process.fill.previous.BooleanPreviousFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.previous.BooleanPreviousFillWithTimeDuration;
+import org.apache.iotdb.calc.execution.operator.process.fill.previous.DoublePreviousFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.previous.DoublePreviousFillWithTimeDuration;
+import org.apache.iotdb.calc.execution.operator.process.fill.previous.FloatPreviousFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.previous.FloatPreviousFillWithTimeDuration;
+import org.apache.iotdb.calc.execution.operator.process.fill.previous.IntPreviousFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.previous.IntPreviousFillWithTimeDuration;
+import org.apache.iotdb.calc.execution.operator.process.fill.previous.LongPreviousFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.previous.LongPreviousFillWithTimeDuration;
+
+import org.apache.tsfile.enums.TSDataType;
+import org.apache.tsfile.read.common.block.column.LongColumn;
+import org.apache.tsfile.utils.TimeDuration;
+
+import java.time.ZoneId;
+import java.util.List;
+import java.util.Optional;
+
+import static org.apache.iotdb.commons.queryengine.utils.TimestampPrecisionUtils.TIMESTAMP_PRECISION;
+
+public class CommonOperatorUtils {
+ public static final IdentityLinearFill IDENTITY_LINEAR_FILL = new IdentityLinearFill();
+ public static final String UNKNOWN_DATATYPE = "Unknown data type: ";
+ public static final String CURRENT_DEVICE_INDEX_STRING = "CurrentDeviceIndex";
+ public static final LongColumn TIME_COLUMN_TEMPLATE =
+ new LongColumn(1, Optional.empty(), new long[] {0});
+ public static final String CURRENT_USED_MEMORY = "CurrentUsedMemory";
+ public static final String MAX_USED_MEMORY = "MaxUsedMemory";
+ public static final String MAX_RESERVED_MEMORY = "MaxReservedMemory";
+ public static final IdentityFill IDENTITY_FILL = new IdentityFill();
+
+ public static ILinearFill[] getLinearFill(int inputColumns, List inputDataTypes) {
+ ILinearFill[] linearFill = new ILinearFill[inputColumns];
+ for (int i = 0; i < inputColumns; i++) {
+ switch (inputDataTypes.get(i)) {
+ case INT32:
+ case DATE:
+ linearFill[i] = new IntLinearFill();
+ break;
+ case INT64:
+ case TIMESTAMP:
+ linearFill[i] = new LongLinearFill();
+ break;
+ case FLOAT:
+ linearFill[i] = new FloatLinearFill();
+ break;
+ case DOUBLE:
+ linearFill[i] = new DoubleLinearFill();
+ break;
+ case BOOLEAN:
+ case TEXT:
+ case STRING:
+ case BLOB:
+ case OBJECT:
+ linearFill[i] = IDENTITY_LINEAR_FILL;
+ break;
+ default:
+ throw new IllegalArgumentException(UNKNOWN_DATATYPE + inputDataTypes.get(i));
+ }
+ }
+ return linearFill;
+ }
+
+ public static IFill[] getPreviousFill(
+ int inputColumns,
+ List inputDataTypes,
+ TimeDuration timeDurationThreshold,
+ ZoneId zoneId) {
+ IFillFilter filter;
+ if (timeDurationThreshold == null) {
+ filter = null;
+ } else if (!timeDurationThreshold.containsMonth()) {
+ filter = new FixedIntervalFillFilter(timeDurationThreshold.nonMonthDuration);
+ } else {
+ switch (TIMESTAMP_PRECISION) {
+ case "ms":
+ filter =
+ new MonthIntervalMSFillFilter(
+ timeDurationThreshold.monthDuration,
+ timeDurationThreshold.nonMonthDuration,
+ zoneId);
+ break;
+ case "us":
+ filter =
+ new MonthIntervalUSFillFilter(
+ timeDurationThreshold.monthDuration,
+ timeDurationThreshold.nonMonthDuration,
+ zoneId);
+ break;
+ case "ns":
+ filter =
+ new MonthIntervalNSFillFilter(
+ timeDurationThreshold.monthDuration,
+ timeDurationThreshold.nonMonthDuration,
+ zoneId);
+ break;
+ default:
+ // this case will never reach
+ throw new UnsupportedOperationException(
+ "not supported time_precision: " + TIMESTAMP_PRECISION);
+ }
+ }
+
+ IFill[] previousFill = new IFill[inputColumns];
+ for (int i = 0; i < inputColumns; i++) {
+ switch (inputDataTypes.get(i)) {
+ case BOOLEAN:
+ previousFill[i] =
+ filter == null
+ ? new BooleanPreviousFill()
+ : new BooleanPreviousFillWithTimeDuration(filter);
+ break;
+ case TEXT:
+ case STRING:
+ case BLOB:
+ case OBJECT:
+ previousFill[i] =
+ filter == null
+ ? new BinaryPreviousFill()
+ : new BinaryPreviousFillWithTimeDuration(filter);
+ break;
+ case INT32:
+ case DATE:
+ previousFill[i] =
+ filter == null ? new IntPreviousFill() : new IntPreviousFillWithTimeDuration(filter);
+ break;
+ case INT64:
+ case TIMESTAMP:
+ previousFill[i] =
+ filter == null
+ ? new LongPreviousFill()
+ : new LongPreviousFillWithTimeDuration(filter);
+ break;
+ case FLOAT:
+ previousFill[i] =
+ filter == null
+ ? new FloatPreviousFill()
+ : new FloatPreviousFillWithTimeDuration(filter);
+ break;
+ case DOUBLE:
+ previousFill[i] =
+ filter == null
+ ? new DoublePreviousFill()
+ : new DoublePreviousFillWithTimeDuration(filter);
+ break;
+ default:
+ throw new IllegalArgumentException(UNKNOWN_DATATYPE + inputDataTypes.get(i));
+ }
+ }
+ return previousFill;
+ }
+}
diff --git a/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/plan/planner/ITableOperatorGeneratorContext.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/plan/planner/ITableOperatorGeneratorContext.java
new file mode 100644
index 0000000000000..ffee1d2e8dace
--- /dev/null
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/plan/planner/ITableOperatorGeneratorContext.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.calc.plan.planner;
+
+import org.apache.iotdb.commons.queryengine.plan.analyze.ITableTypeProvider;
+
+import java.time.ZoneId;
+
+public interface ITableOperatorGeneratorContext {
+ ITableTypeProvider getTableTypeProvider();
+
+ ZoneId getZoneId();
+}
diff --git a/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/plan/planner/TableOperatorGenerator.java b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/plan/planner/TableOperatorGenerator.java
new file mode 100644
index 0000000000000..aebce95bdb9e3
--- /dev/null
+++ b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/plan/planner/TableOperatorGenerator.java
@@ -0,0 +1,2280 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.calc.plan.planner;
+
+import org.apache.iotdb.calc.execution.operator.CommonOperatorContext;
+import org.apache.iotdb.calc.execution.operator.Operator;
+import org.apache.iotdb.calc.execution.operator.process.AssignUniqueIdOperator;
+import org.apache.iotdb.calc.execution.operator.process.CollectOperator;
+import org.apache.iotdb.calc.execution.operator.process.EnforceSingleRowOperator;
+import org.apache.iotdb.calc.execution.operator.process.FilterAndProjectOperator;
+import org.apache.iotdb.calc.execution.operator.process.LimitOperator;
+import org.apache.iotdb.calc.execution.operator.process.MappingCollectOperator;
+import org.apache.iotdb.calc.execution.operator.process.OffsetOperator;
+import org.apache.iotdb.calc.execution.operator.process.PatternRecognitionOperator;
+import org.apache.iotdb.calc.execution.operator.process.PreviousFillWithGroupOperator;
+import org.apache.iotdb.calc.execution.operator.process.TableFillOperator;
+import org.apache.iotdb.calc.execution.operator.process.TableLinearFillOperator;
+import org.apache.iotdb.calc.execution.operator.process.TableLinearFillWithGroupOperator;
+import org.apache.iotdb.calc.execution.operator.process.TableMergeSortOperator;
+import org.apache.iotdb.calc.execution.operator.process.TableSortOperator;
+import org.apache.iotdb.calc.execution.operator.process.TableStreamSortOperator;
+import org.apache.iotdb.calc.execution.operator.process.TableTopKOperator;
+import org.apache.iotdb.calc.execution.operator.process.ValuesOperator;
+import org.apache.iotdb.calc.execution.operator.process.fill.IFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.ILinearFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.constant.BinaryConstantFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.constant.BooleanConstantFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.constant.DoubleConstantFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.constant.FloatConstantFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.constant.IntConstantFill;
+import org.apache.iotdb.calc.execution.operator.process.fill.constant.LongConstantFill;
+import org.apache.iotdb.calc.execution.operator.process.function.TableFunctionLeafOperator;
+import org.apache.iotdb.calc.execution.operator.process.function.TableFunctionOperator;
+import org.apache.iotdb.calc.execution.operator.process.gapfill.GapFillWGroupWMoOperator;
+import org.apache.iotdb.calc.execution.operator.process.gapfill.GapFillWGroupWoMoOperator;
+import org.apache.iotdb.calc.execution.operator.process.gapfill.GapFillWoGroupWMoOperator;
+import org.apache.iotdb.calc.execution.operator.process.gapfill.GapFillWoGroupWoMoOperator;
+import org.apache.iotdb.calc.execution.operator.process.join.SimpleNestedLoopCrossJoinOperator;
+import org.apache.iotdb.calc.execution.operator.process.join.merge.comparator.JoinKeyComparatorFactory;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.LogicalIndexNavigation;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.PatternAggregationTracker;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.PatternAggregator;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.PatternVariableRecognizer;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.PhysicalAggregationPointer;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.PhysicalValueAccessor;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.PhysicalValuePointer;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.expression.Computation;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.expression.PatternExpressionComputation;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher.IrRowPatternToProgramRewriter;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher.Matcher;
+import org.apache.iotdb.calc.execution.operator.process.rowpattern.matcher.Program;
+import org.apache.iotdb.calc.execution.operator.process.window.RowNumberOperator;
+import org.apache.iotdb.calc.execution.operator.process.window.TableWindowOperator;
+import org.apache.iotdb.calc.execution.operator.process.window.TopKRankingOperator;
+import org.apache.iotdb.calc.execution.operator.process.window.function.WindowFunction;
+import org.apache.iotdb.calc.execution.operator.process.window.function.WindowFunctionFactory;
+import org.apache.iotdb.calc.execution.operator.process.window.function.aggregate.AggregationWindowFunction;
+import org.apache.iotdb.calc.execution.operator.process.window.function.aggregate.WindowAggregator;
+import org.apache.iotdb.calc.execution.operator.process.window.partition.frame.FrameInfo;
+import org.apache.iotdb.calc.execution.operator.source.relational.AsofMergeSortInnerJoinOperator;
+import org.apache.iotdb.calc.execution.operator.source.relational.AsofMergeSortLeftJoinOperator;
+import org.apache.iotdb.calc.execution.operator.source.relational.MarkDistinctOperator;
+import org.apache.iotdb.calc.execution.operator.source.relational.MergeSortFullOuterJoinOperator;
+import org.apache.iotdb.calc.execution.operator.source.relational.MergeSortInnerJoinOperator;
+import org.apache.iotdb.calc.execution.operator.source.relational.MergeSortLeftJoinOperator;
+import org.apache.iotdb.calc.execution.operator.source.relational.MergeSortSemiJoinOperator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AggregationOperator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.LastByDescAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.LastDescAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.TableAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.TableAggregator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedAccumulator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.GroupedAggregator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.HashAggregationOperator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.StreamingAggregationOperator;
+import org.apache.iotdb.calc.execution.operator.source.relational.aggregation.grouped.StreamingHashAggregationOperator;
+import org.apache.iotdb.calc.execution.relational.ColumnTransformerBuilder;
+import org.apache.iotdb.calc.plan.relational.metadata.ITypeMetadata;
+import org.apache.iotdb.calc.plan.relational.planner.CastToBlobLiteralVisitor;
+import org.apache.iotdb.calc.plan.relational.planner.CastToBooleanLiteralVisitor;
+import org.apache.iotdb.calc.plan.relational.planner.CastToDateLiteralVisitor;
+import org.apache.iotdb.calc.plan.relational.planner.CastToDoubleLiteralVisitor;
+import org.apache.iotdb.calc.plan.relational.planner.CastToFloatLiteralVisitor;
+import org.apache.iotdb.calc.plan.relational.planner.CastToInt32LiteralVisitor;
+import org.apache.iotdb.calc.plan.relational.planner.CastToInt64LiteralVisitor;
+import org.apache.iotdb.calc.plan.relational.planner.CastToStringLiteralVisitor;
+import org.apache.iotdb.calc.plan.relational.planner.CastToTimestampLiteralVisitor;
+import org.apache.iotdb.calc.transformation.dag.column.ColumnTransformer;
+import org.apache.iotdb.calc.transformation.dag.column.leaf.LeafColumnTransformer;
+import org.apache.iotdb.calc.utils.datastructure.SortKey;
+import org.apache.iotdb.commons.exception.SemanticException;
+import org.apache.iotdb.commons.queryengine.common.SessionInfo;
+import org.apache.iotdb.commons.queryengine.plan.analyze.ITableTypeProvider;
+import org.apache.iotdb.commons.queryengine.plan.planner.plan.node.ICoreQueryPlanVisitor;
+import org.apache.iotdb.commons.queryengine.plan.planner.plan.node.PlanNode;
+import org.apache.iotdb.commons.queryengine.plan.planner.plan.node.PlanNodeId;
+import org.apache.iotdb.commons.queryengine.plan.planner.plan.node.process.SingleChildProcessNode;
+import org.apache.iotdb.commons.queryengine.plan.planner.plan.parameter.InputLocation;
+import org.apache.iotdb.commons.queryengine.plan.relational.function.BoundSignature;
+import org.apache.iotdb.commons.queryengine.plan.relational.function.FunctionKind;
+import org.apache.iotdb.commons.queryengine.plan.relational.function.ITableFunctionFactory;
+import org.apache.iotdb.commons.queryengine.plan.relational.metadata.ResolvedFunction;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.OrderingScheme;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.SortOrder;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.Symbol;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.AggregationNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.AssignUniqueId;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.CollectNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.EnforceSingleRowNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.FilterNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.GapFillNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.GroupNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.JoinNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.LimitNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.LinearFillNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.MarkDistinctNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.Measure;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.MergeSortNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.OffsetNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.OutputNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.PatternRecognitionNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.PreviousFillNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.ProjectNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.RowNumberNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.SemiJoinNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.SortNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.StreamSortNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.TableFunctionNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.TableFunctionProcessorNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.TopKNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.TopKRankingNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.UnionNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.ValueFillNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.ValuesNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.node.WindowNode;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.AggregationLabelSet;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.AggregationValuePointer;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.ClassifierValuePointer;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.ExpressionAndValuePointers;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.IrLabel;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.LogicalIndexPointer;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.MatchNumberValuePointer;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.ScalarValuePointer;
+import org.apache.iotdb.commons.queryengine.plan.relational.planner.rowpattern.ValuePointer;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.ComparisonExpression;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.Expression;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.Literal;
+import org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.SymbolReference;
+import org.apache.iotdb.commons.queryengine.plan.relational.type.InternalTypeManager;
+import org.apache.iotdb.udf.api.relational.TableFunction;
+import org.apache.iotdb.udf.api.relational.table.TableFunctionProcessorProvider;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ListMultimap;
+import org.apache.tsfile.block.column.Column;
+import org.apache.tsfile.common.conf.TSFileConfig;
+import org.apache.tsfile.common.conf.TSFileDescriptor;
+import org.apache.tsfile.enums.TSDataType;
+import org.apache.tsfile.read.common.block.column.BinaryColumn;
+import org.apache.tsfile.read.common.block.column.BooleanColumn;
+import org.apache.tsfile.read.common.block.column.DoubleColumn;
+import org.apache.tsfile.read.common.block.column.FloatColumn;
+import org.apache.tsfile.read.common.block.column.IntColumn;
+import org.apache.tsfile.read.common.block.column.LongColumn;
+import org.apache.tsfile.read.common.type.Type;
+import org.apache.tsfile.utils.Binary;
+
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.OptionalInt;
+import java.util.Set;
+import java.util.function.BiFunction;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.ImmutableList.toImmutableList;
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static java.util.Objects.requireNonNull;
+import static org.apache.iotdb.calc.execution.operator.process.join.merge.MergeSortComparator.getComparatorForTable;
+import static org.apache.iotdb.calc.execution.operator.process.rowpattern.PhysicalValuePointer.CLASSIFIER;
+import static org.apache.iotdb.calc.execution.operator.process.rowpattern.PhysicalValuePointer.MATCH_NUMBER;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AccumulatorFactory.createAccumulator;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AccumulatorFactory.createBuiltinAccumulator;
+import static org.apache.iotdb.calc.execution.operator.source.relational.aggregation.AccumulatorFactory.createGroupedAccumulator;
+import static org.apache.iotdb.calc.plan.planner.CommonOperatorUtils.IDENTITY_FILL;
+import static org.apache.iotdb.calc.plan.planner.CommonOperatorUtils.UNKNOWN_DATATYPE;
+import static org.apache.iotdb.calc.plan.planner.CommonOperatorUtils.getLinearFill;
+import static org.apache.iotdb.calc.plan.planner.CommonOperatorUtils.getPreviousFill;
+import static org.apache.iotdb.calc.utils.constant.SqlConstant.FIRST_AGGREGATION;
+import static org.apache.iotdb.calc.utils.constant.SqlConstant.FIRST_BY_AGGREGATION;
+import static org.apache.iotdb.calc.utils.constant.SqlConstant.LAST_AGGREGATION;
+import static org.apache.iotdb.calc.utils.constant.SqlConstant.LAST_BY_AGGREGATION;
+import static org.apache.iotdb.commons.queryengine.execution.operator.source.relational.aggregation.grouped.hash.GroupByHash.DEFAULT_GROUP_NUMBER;
+import static org.apache.iotdb.commons.queryengine.plan.relational.planner.SortOrder.ASC_NULLS_FIRST;
+import static org.apache.iotdb.commons.queryengine.plan.relational.planner.SortOrder.ASC_NULLS_LAST;
+import static org.apache.iotdb.commons.queryengine.plan.relational.planner.SortOrder.DESC_NULLS_FIRST;
+import static org.apache.iotdb.commons.queryengine.plan.relational.planner.SortOrder.DESC_NULLS_LAST;
+import static org.apache.iotdb.commons.queryengine.plan.relational.planner.node.RowsPerMatch.ONE;
+import static org.apache.iotdb.commons.queryengine.plan.relational.planner.node.SkipToPosition.LAST;
+import static org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.BooleanLiteral.TRUE_LITERAL;
+import static org.apache.iotdb.commons.queryengine.plan.relational.type.InternalTypeManager.getTSDataType;
+import static org.apache.iotdb.commons.udf.builtin.relational.TableBuiltinAggregationFunction.getAggregationTypeByFuncName;
+import static org.apache.tsfile.read.common.type.LongType.INT64;
+import static org.apache.tsfile.read.common.type.StringType.STRING;
+import static org.apache.tsfile.read.common.type.TimestampType.TIMESTAMP;
+
+/** This Visitor is responsible for transferring Table PlanNode Tree to Table Operator Tree. */
+public abstract class TableOperatorGenerator<
+ C extends ITableOperatorGeneratorContext, M extends ITypeMetadata & ITableFunctionFactory>
+ implements ICoreQueryPlanVisitor {
+
+ protected final M metadata;
+
+ public TableOperatorGenerator(M metadata) {
+ this.metadata = metadata;
+ }
+
+ @Override
+ public Operator visitPlan(PlanNode node, C context) {
+ throw new UnsupportedOperationException("should call the concrete visitXX() method");
+ }
+
+ public static Map> makeLayout(final List children) {
+ final Map> outputMappings = new LinkedHashMap<>();
+ int tsBlockIndex = 0;
+ for (final PlanNode childNode : children) {
+ int valueColumnIndex = 0;
+ for (final Symbol columnName : childNode.getOutputSymbols()) {
+ outputMappings
+ .computeIfAbsent(columnName, key -> new ArrayList<>())
+ .add(new InputLocation(tsBlockIndex, valueColumnIndex));
+ valueColumnIndex++;
+ }
+ tsBlockIndex++;
+ }
+ return outputMappings;
+ }
+
+ protected ImmutableMap makeLayoutFromOutputSymbols(List outputSymbols) {
+ if (outputSymbols == null) {
+ return ImmutableMap.of();
+ }
+ ImmutableMap.Builder outputMappings = ImmutableMap.builder();
+ int channel = 0;
+ for (Symbol symbol : outputSymbols) {
+ outputMappings.put(symbol, channel);
+ channel++;
+ }
+ return outputMappings.buildOrThrow();
+ }
+
+ @Override
+ public Operator visitFilter(FilterNode node, C context) {
+ ITableTypeProvider typeProvider = context.getTableTypeProvider();
+ Optional predicate = Optional.of(node.getPredicate());
+ Operator inputOperator = node.getChild().accept(this, context);
+ List inputDataTypes = getInputColumnTypes(node, typeProvider);
+ Map> inputLocations = makeLayout(node.getChildren());
+
+ return constructFilterAndProjectOperator(
+ predicate,
+ inputOperator,
+ node.getOutputSymbols().stream().map(Symbol::toSymbolReference).toArray(Expression[]::new),
+ inputDataTypes,
+ inputLocations,
+ node.getPlanNodeId(),
+ context);
+ }
+
+ protected Operator constructFilterAndProjectOperator(
+ Optional predicate,
+ Operator inputOperator,
+ Expression[] projectExpressions,
+ List inputDataTypes,
+ Map> inputLocations,
+ PlanNodeId planNodeId,
+ C context) {
+
+ final List filterOutputDataTypes = new ArrayList<>(inputDataTypes);
+
+ // records LeafColumnTransformer of filter
+ List filterLeafColumnTransformerList = new ArrayList<>();
+
+ // records subexpression -> ColumnTransformer for filter
+ Map filterExpressionColumnTransformerMap = new HashMap<>();
+
+ ColumnTransformerBuilder visitor = new ColumnTransformerBuilder();
+
+ SessionInfo sessionInfo = getSessionInfo(context);
+ ColumnTransformer filterOutputTransformer =
+ predicate
+ .map(
+ p -> {
+ ColumnTransformerBuilder.Context filterColumnTransformerContext =
+ new ColumnTransformerBuilder.Context(
+ sessionInfo,
+ filterLeafColumnTransformerList,
+ inputLocations,
+ filterExpressionColumnTransformerMap,
+ ImmutableMap.of(),
+ ImmutableList.of(),
+ ImmutableList.of(),
+ 0,
+ context.getTableTypeProvider(),
+ metadata);
+
+ return visitor.process(p, filterColumnTransformerContext);
+ })
+ .orElse(null);
+
+ // records LeafColumnTransformer of project expressions
+ List projectLeafColumnTransformerList = new ArrayList<>();
+
+ List projectOutputTransformerList = new ArrayList<>();
+
+ Map projectExpressionColumnTransformerMap = new HashMap<>();
+
+ // records common ColumnTransformer between filter and project expressions
+ List commonTransformerList = new ArrayList<>();
+
+ ColumnTransformerBuilder.Context projectColumnTransformerContext =
+ new ColumnTransformerBuilder.Context(
+ sessionInfo,
+ projectLeafColumnTransformerList,
+ inputLocations,
+ projectExpressionColumnTransformerMap,
+ filterExpressionColumnTransformerMap,
+ commonTransformerList,
+ filterOutputDataTypes,
+ inputLocations.size(),
+ context.getTableTypeProvider(),
+ metadata);
+
+ for (Expression expression : projectExpressions) {
+ projectOutputTransformerList.add(
+ visitor.process(expression, projectColumnTransformerContext));
+ }
+
+ final CommonOperatorContext operatorContext =
+ addOperatorContext(context, planNodeId, FilterAndProjectOperator.class.getSimpleName());
+
+ // Project expressions don't contain Non-Mappable UDF, TransformOperator is not needed
+ return new FilterAndProjectOperator(
+ operatorContext,
+ inputOperator,
+ filterOutputDataTypes,
+ filterLeafColumnTransformerList,
+ filterOutputTransformer,
+ commonTransformerList,
+ projectLeafColumnTransformerList,
+ projectOutputTransformerList,
+ false,
+ predicate.isPresent());
+ }
+
+ @Override
+ public Operator visitProject(ProjectNode node, C context) {
+ ITableTypeProvider typeProvider = context.getTableTypeProvider();
+ Optional predicate;
+ Operator inputOperator;
+ List inputDataTypes;
+ Map> inputLocations;
+ if (node.getChild() instanceof FilterNode) {
+ FilterNode filterNode = (FilterNode) node.getChild();
+ predicate = Optional.of(filterNode.getPredicate());
+ inputOperator = filterNode.getChild().accept(this, context);
+ inputDataTypes = getInputColumnTypes(filterNode, typeProvider);
+ inputLocations = makeLayout(filterNode.getChildren());
+ } else {
+ predicate = Optional.empty();
+ inputOperator = node.getChild().accept(this, context);
+ inputDataTypes = getInputColumnTypes(node, typeProvider);
+ inputLocations = makeLayout(node.getChildren());
+ }
+
+ return constructFilterAndProjectOperator(
+ predicate,
+ inputOperator,
+ node.getAssignments().getMap().values().toArray(new Expression[0]),
+ inputDataTypes,
+ inputLocations,
+ node.getPlanNodeId(),
+ context);
+ }
+
+ private List getInputColumnTypes(PlanNode node, ITableTypeProvider typeProvider) {
+ // ignore "time" column
+ return node.getChildren().stream()
+ .map(PlanNode::getOutputSymbols)
+ .flatMap(List::stream)
+ .map(s -> getTSDataType(typeProvider.getTableModelType(s)))
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public Operator visitGapFill(GapFillNode node, C context) {
+ Operator child = node.getChild().accept(this, context);
+ List inputDataTypes =
+ getOutputColumnTypes(node.getChild(), context.getTableTypeProvider());
+ int timeColumnIndex = getColumnIndex(node.getGapFillColumn(), node.getChild());
+ if (node.getGapFillGroupingKeys().isEmpty()) { // without group keys
+ if (node.getMonthDuration() == 0) { // without month interval
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), GapFillWoGroupWoMoOperator.class.getSimpleName());
+ return new GapFillWoGroupWoMoOperator(
+ operatorContext,
+ child,
+ timeColumnIndex,
+ node.getStartTime(),
+ node.getEndTime(),
+ inputDataTypes,
+ node.getNonMonthDuration());
+ } else { // with month interval
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), GapFillWoGroupWMoOperator.class.getSimpleName());
+ return new GapFillWoGroupWMoOperator(
+ operatorContext,
+ child,
+ timeColumnIndex,
+ node.getStartTime(),
+ node.getEndTime(),
+ inputDataTypes,
+ node.getMonthDuration(),
+ context.getZoneId());
+ }
+
+ } else { // with group keys
+ Set groupingKeysIndexSet = new HashSet<>();
+ Comparator groupKeyComparator =
+ genFillGroupKeyComparator(
+ node.getGapFillGroupingKeys(), node, inputDataTypes, groupingKeysIndexSet);
+ if (node.getMonthDuration() == 0) { // without month interval
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), GapFillWGroupWoMoOperator.class.getSimpleName());
+ return new GapFillWGroupWoMoOperator(
+ operatorContext,
+ child,
+ timeColumnIndex,
+ node.getStartTime(),
+ node.getEndTime(),
+ groupKeyComparator,
+ inputDataTypes,
+ groupingKeysIndexSet,
+ node.getNonMonthDuration());
+ } else { // with month interval
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), GapFillWGroupWMoOperator.class.getSimpleName());
+ return new GapFillWGroupWMoOperator(
+ operatorContext,
+ child,
+ timeColumnIndex,
+ node.getStartTime(),
+ node.getEndTime(),
+ groupKeyComparator,
+ inputDataTypes,
+ groupingKeysIndexSet,
+ node.getMonthDuration(),
+ context.getZoneId());
+ }
+ }
+ }
+
+ @Override
+ public Operator visitPreviousFill(PreviousFillNode node, C context) {
+ Operator child = node.getChild().accept(this, context);
+
+ List inputDataTypes =
+ getOutputColumnTypes(node.getChild(), context.getTableTypeProvider());
+ int inputColumnCount = inputDataTypes.size();
+ int helperColumnIndex = -1;
+ if (node.getHelperColumn().isPresent()) {
+ helperColumnIndex = getColumnIndex(node.getHelperColumn().get(), node.getChild());
+ }
+ IFill[] fillArray =
+ getPreviousFill(
+ inputColumnCount,
+ inputDataTypes,
+ node.getTimeBound().orElse(null),
+ context.getZoneId());
+
+ if (node.getGroupingKeys().isPresent()) {
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), PreviousFillWithGroupOperator.class.getSimpleName());
+ return new PreviousFillWithGroupOperator(
+ operatorContext,
+ fillArray,
+ child,
+ helperColumnIndex,
+ genFillGroupKeyComparator(
+ node.getGroupingKeys().get(), node, inputDataTypes, new HashSet<>()),
+ inputDataTypes);
+ } else {
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), TableFillOperator.class.getSimpleName());
+ return new TableFillOperator(operatorContext, fillArray, child, helperColumnIndex);
+ }
+ }
+
+ // used by fill and gapfill
+ private Comparator genFillGroupKeyComparator(
+ List groupingKeys,
+ SingleChildProcessNode node,
+ List inputDataTypes,
+ Set groupKeysIndex) {
+ int groupKeysCount = groupingKeys.size();
+ List sortOrderList = new ArrayList<>(groupKeysCount);
+ List groupItemIndexList = new ArrayList<>(groupKeysCount);
+ List groupItemDataTypeList = new ArrayList<>(groupKeysCount);
+ Map columnIndex =
+ makeLayoutFromOutputSymbols(node.getChild().getOutputSymbols());
+ for (Symbol symbol : groupingKeys) {
+ // sort order for fill_group should always be ASC_NULLS_LAST, it should be same as
+ // QueryPlanner.fillGroup
+ sortOrderList.add(ASC_NULLS_LAST);
+ int index = columnIndex.get(symbol);
+ groupItemIndexList.add(index);
+ groupItemDataTypeList.add(inputDataTypes.get(index));
+ }
+ groupKeysIndex.addAll(groupItemIndexList);
+ return getComparatorForTable(sortOrderList, groupItemIndexList, groupItemDataTypeList);
+ }
+
+ // index starts from 0
+ private int getColumnIndex(Symbol symbol, PlanNode node) {
+ String name = symbol.getName();
+ int channel = 0;
+ for (Symbol columnName : node.getOutputSymbols()) {
+ if (columnName.getName().equals(name)) {
+ return channel;
+ }
+ channel++;
+ }
+ throw new IllegalStateException(
+ String.format("Found no column %s in %s", symbol, node.getOutputSymbols()));
+ }
+
+ @Override
+ public Operator visitLinearFill(LinearFillNode node, C context) {
+ Operator child = node.getChild().accept(this, context);
+
+ List inputDataTypes =
+ getOutputColumnTypes(node.getChild(), context.getTableTypeProvider());
+ int inputColumnCount = inputDataTypes.size();
+ int helperColumnIndex = getColumnIndex(node.getHelperColumn(), node.getChild());
+ ILinearFill[] fillArray = getLinearFill(inputColumnCount, inputDataTypes);
+
+ if (node.getGroupingKeys().isPresent()) {
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context,
+ node.getPlanNodeId(),
+ TableLinearFillWithGroupOperator.class.getSimpleName());
+ return new TableLinearFillWithGroupOperator(
+ operatorContext,
+ fillArray,
+ child,
+ helperColumnIndex,
+ genFillGroupKeyComparator(
+ node.getGroupingKeys().get(), node, inputDataTypes, new HashSet<>()),
+ inputDataTypes);
+ } else {
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), TableLinearFillOperator.class.getSimpleName());
+ return new TableLinearFillOperator(operatorContext, fillArray, child, helperColumnIndex);
+ }
+ }
+
+ @Override
+ public Operator visitValueFill(ValueFillNode node, C context) {
+ Operator child = node.getChild().accept(this, context);
+ CommonOperatorContext operatorContext =
+ addOperatorContext(context, node.getPlanNodeId(), TableFillOperator.class.getSimpleName());
+ List inputDataTypes =
+ getOutputColumnTypes(node.getChild(), context.getTableTypeProvider());
+ int inputColumnCount = inputDataTypes.size();
+ Literal filledValue = node.getFilledValue();
+ return new TableFillOperator(
+ operatorContext,
+ getValueFill(inputColumnCount, inputDataTypes, filledValue, context),
+ child,
+ -1);
+ }
+
+ private IFill[] getValueFill(
+ int inputColumnCount, List inputDataTypes, Literal filledValue, C context) {
+ IFill[] constantFill = new IFill[inputColumnCount];
+ for (int i = 0; i < inputColumnCount; i++) {
+ switch (inputDataTypes.get(i)) {
+ case BOOLEAN:
+ Boolean bool = filledValue.accept(new CastToBooleanLiteralVisitor(), null);
+ if (bool == null) {
+ constantFill[i] = IDENTITY_FILL;
+ } else {
+ constantFill[i] = new BooleanConstantFill(bool);
+ }
+ break;
+ case TEXT:
+ case STRING:
+ Binary binary =
+ filledValue.accept(new CastToStringLiteralVisitor(TSFileConfig.STRING_CHARSET), null);
+ if (binary == null) {
+ constantFill[i] = IDENTITY_FILL;
+ } else {
+ constantFill[i] = new BinaryConstantFill(binary);
+ }
+ break;
+ case BLOB:
+ Binary blob = filledValue.accept(new CastToBlobLiteralVisitor(), null);
+ if (blob == null) {
+ constantFill[i] = IDENTITY_FILL;
+ } else {
+ constantFill[i] = new BinaryConstantFill(blob);
+ }
+ break;
+ case INT32:
+ Integer intValue = filledValue.accept(new CastToInt32LiteralVisitor(), null);
+ if (intValue == null) {
+ constantFill[i] = IDENTITY_FILL;
+ } else {
+ constantFill[i] = new IntConstantFill(intValue);
+ }
+ break;
+ case DATE:
+ Integer dateValue = filledValue.accept(new CastToDateLiteralVisitor(), null);
+ if (dateValue == null) {
+ constantFill[i] = IDENTITY_FILL;
+ } else {
+ constantFill[i] = new IntConstantFill(dateValue);
+ }
+ break;
+ case INT64:
+ Long longValue = filledValue.accept(new CastToInt64LiteralVisitor(), null);
+ if (longValue == null) {
+ constantFill[i] = IDENTITY_FILL;
+ } else {
+ constantFill[i] = new LongConstantFill(longValue);
+ }
+ break;
+ case TIMESTAMP:
+ Long timestampValue =
+ filledValue.accept(new CastToTimestampLiteralVisitor(context.getZoneId()), null);
+ if (timestampValue == null) {
+ constantFill[i] = IDENTITY_FILL;
+ } else {
+ constantFill[i] = new LongConstantFill(timestampValue);
+ }
+ break;
+ case FLOAT:
+ Float floatValue = filledValue.accept(new CastToFloatLiteralVisitor(), null);
+ if (floatValue == null) {
+ constantFill[i] = IDENTITY_FILL;
+ } else {
+ constantFill[i] = new FloatConstantFill(floatValue);
+ }
+ break;
+ case DOUBLE:
+ Double doubleValue = filledValue.accept(new CastToDoubleLiteralVisitor(), null);
+ if (doubleValue == null) {
+ constantFill[i] = IDENTITY_FILL;
+ } else {
+ constantFill[i] = new DoubleConstantFill(doubleValue);
+ }
+ break;
+ default:
+ throw new IllegalArgumentException(UNKNOWN_DATATYPE + inputDataTypes.get(i));
+ }
+ }
+ return constantFill;
+ }
+
+ @Override
+ public Operator visitLimit(LimitNode node, C context) {
+ Operator child = node.getChild().accept(this, context);
+ CommonOperatorContext operatorContext =
+ addOperatorContext(context, node.getPlanNodeId(), LimitOperator.class.getSimpleName());
+
+ return new LimitOperator(operatorContext, node.getCount(), child);
+ }
+
+ @Override
+ public Operator visitOffset(OffsetNode node, C context) {
+ Operator child = node.getChild().accept(this, context);
+ CommonOperatorContext operatorContext =
+ addOperatorContext(context, node.getPlanNodeId(), OffsetOperator.class.getSimpleName());
+
+ return new OffsetOperator(operatorContext, node.getCount(), child);
+ }
+
+ @Override
+ public Operator visitOutput(OutputNode node, C context) {
+ return node.getChild().accept(this, context);
+ }
+
+ @Override
+ public Operator visitCollect(CollectNode node, C context) {
+ CommonOperatorContext operatorContext =
+ addOperatorContext(context, node.getPlanNodeId(), CollectOperator.class.getSimpleName());
+ List children = new ArrayList<>(node.getChildren().size());
+ for (PlanNode child : node.getChildren()) {
+ children.add(this.process(child, context));
+ }
+ return new CollectOperator(operatorContext, children);
+ }
+
+ @Override
+ public Operator visitMergeSort(MergeSortNode node, C context) {
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), TableMergeSortOperator.class.getSimpleName());
+ List children = new ArrayList<>(node.getChildren().size());
+ for (PlanNode child : node.getChildren()) {
+ children.add(this.process(child, context));
+ }
+ List dataTypes = getOutputColumnTypes(node, context.getTableTypeProvider());
+ int sortItemsCount = node.getOrderingScheme().getOrderBy().size();
+
+ List sortItemIndexList = new ArrayList<>(sortItemsCount);
+ List sortItemDataTypeList = new ArrayList<>(sortItemsCount);
+ genSortInformation(
+ node.getOutputSymbols(),
+ node.getOrderingScheme(),
+ sortItemIndexList,
+ sortItemDataTypeList,
+ context.getTableTypeProvider());
+
+ return new TableMergeSortOperator(
+ operatorContext,
+ children,
+ dataTypes,
+ getComparatorForTable(
+ node.getOrderingScheme().getOrderingList(), sortItemIndexList, sortItemDataTypeList));
+ }
+
+ @Override
+ public Operator visitSort(SortNode node, C context) {
+ CommonOperatorContext operatorContext =
+ addOperatorContext(context, node.getPlanNodeId(), TableSortOperator.class.getSimpleName());
+ List dataTypes = getOutputColumnTypes(node, context.getTableTypeProvider());
+ int sortItemsCount = node.getOrderingScheme().getOrderBy().size();
+
+ List sortItemIndexList = new ArrayList<>(sortItemsCount);
+ List sortItemDataTypeList = new ArrayList<>(sortItemsCount);
+ genSortInformation(
+ node.getOutputSymbols(),
+ node.getOrderingScheme(),
+ sortItemIndexList,
+ sortItemDataTypeList,
+ context.getTableTypeProvider());
+
+ Operator child = node.getChild().accept(this, context);
+
+ return new TableSortOperator(
+ operatorContext,
+ child,
+ dataTypes,
+ getSortTmpDir(operatorContext),
+ getComparatorForTable(
+ node.getOrderingScheme().getOrderingList(), sortItemIndexList, sortItemDataTypeList));
+ }
+
+ protected abstract String getSortTmpDir(CommonOperatorContext operatorContext);
+
+ protected abstract CommonOperatorContext addOperatorContext(
+ C context, PlanNodeId planNodeId, String operatorType);
+
+ @Override
+ public Operator visitTopK(TopKNode node, C context) {
+ CommonOperatorContext operatorContext =
+ addOperatorContext(context, node.getPlanNodeId(), TableTopKOperator.class.getSimpleName());
+ List children = new ArrayList<>(node.getChildren().size());
+ for (PlanNode child : node.getChildren()) {
+ children.add(this.process(child, context));
+ }
+ List dataTypes = getOutputColumnTypes(node, context.getTableTypeProvider());
+ int sortItemsCount = node.getOrderingScheme().getOrderBy().size();
+
+ List sortItemIndexList = new ArrayList<>(sortItemsCount);
+ List sortItemDataTypeList = new ArrayList<>(sortItemsCount);
+ genSortInformation(
+ node.getOutputSymbols(),
+ node.getOrderingScheme(),
+ sortItemIndexList,
+ sortItemDataTypeList,
+ context.getTableTypeProvider());
+ return new TableTopKOperator(
+ operatorContext,
+ children,
+ dataTypes,
+ getComparatorForTable(
+ node.getOrderingScheme().getOrderingList(), sortItemIndexList, sortItemDataTypeList),
+ (int) node.getCount(),
+ node.isChildrenDataInOrder());
+ }
+
+ protected List getOutputColumnTypes(PlanNode node, ITableTypeProvider typeProvider) {
+ return node.getOutputSymbols().stream()
+ .map(s -> getTSDataType(typeProvider.getTableModelType(s)))
+ .collect(Collectors.toList());
+ }
+
+ protected void genSortInformation(
+ List outputSymbols,
+ OrderingScheme orderingScheme,
+ List sortItemIndexList,
+ List sortItemDataTypeList,
+ ITableTypeProvider typeProvider) {
+ Map columnIndex = new HashMap<>();
+ int index = 0;
+ for (Symbol symbol : outputSymbols) {
+ columnIndex.put(symbol, index++);
+ }
+ orderingScheme
+ .getOrderBy()
+ .forEach(
+ sortItem -> {
+ Integer i = columnIndex.get(sortItem);
+ if (i == null) {
+ throw new IllegalStateException(
+ String.format(
+ "Sort Item %s is not included in children's output columns", sortItem));
+ }
+ sortItemIndexList.add(i);
+ sortItemDataTypeList.add(getTSDataType(typeProvider.getTableModelType(sortItem)));
+ });
+ }
+
+ @Override
+ public Operator visitStreamSort(StreamSortNode node, C context) {
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), TableStreamSortOperator.class.getSimpleName());
+ List dataTypes = getOutputColumnTypes(node, context.getTableTypeProvider());
+ int sortItemsCount = node.getOrderingScheme().getOrderBy().size();
+
+ List sortItemIndexList = new ArrayList<>(sortItemsCount);
+ List sortItemDataTypeList = new ArrayList<>(sortItemsCount);
+ genSortInformation(
+ node.getOutputSymbols(),
+ node.getOrderingScheme(),
+ sortItemIndexList,
+ sortItemDataTypeList,
+ context.getTableTypeProvider());
+
+ Operator child = node.getChild().accept(this, context);
+
+ return new TableStreamSortOperator(
+ operatorContext,
+ child,
+ dataTypes,
+ getSortTmpDir(operatorContext),
+ getComparatorForTable(
+ node.getOrderingScheme().getOrderingList(), sortItemIndexList, sortItemDataTypeList),
+ getComparatorForTable(
+ node.getOrderingScheme()
+ .getOrderingList()
+ .subList(0, node.getStreamCompareKeyEndIndex() + 1),
+ sortItemIndexList.subList(0, node.getStreamCompareKeyEndIndex() + 1),
+ sortItemDataTypeList.subList(0, node.getStreamCompareKeyEndIndex() + 1)),
+ TSFileDescriptor.getInstance().getConfig().getMaxTsBlockLineNumber());
+ }
+
+ @Override
+ public Operator visitGroup(GroupNode node, C context) {
+ if (node.getPartitionKeyCount() == 0) {
+ SortNode sortNode =
+ new SortNode(
+ node.getPlanNodeId(), node.getChild(), node.getOrderingScheme(), false, false);
+ return visitSort(sortNode, context);
+ } else {
+ StreamSortNode streamSortNode =
+ new StreamSortNode(
+ node.getPlanNodeId(),
+ node.getChild(),
+ node.getOrderingScheme(),
+ false,
+ false,
+ node.getPartitionKeyCount() - 1);
+ return visitStreamSort(streamSortNode, context);
+ }
+ }
+
+ @Override
+ public Operator visitJoin(JoinNode node, C context) {
+ List dataTypes = getOutputColumnTypes(node, context.getTableTypeProvider());
+
+ Operator leftChild = node.getLeftChild().accept(this, context);
+ Operator rightChild = node.getRightChild().accept(this, context);
+
+ ImmutableMap leftColumnNamesMap =
+ makeLayoutFromOutputSymbols(node.getLeftChild().getOutputSymbols());
+ int[] leftOutputSymbolIdx = new int[node.getLeftOutputSymbols().size()];
+ for (int i = 0; i < leftOutputSymbolIdx.length; i++) {
+ Integer index = leftColumnNamesMap.get(node.getLeftOutputSymbols().get(i));
+ if (index == null) {
+ throw new IllegalStateException(
+ "Left child of JoinNode doesn't contain LeftOutputSymbol "
+ + node.getLeftOutputSymbols().get(i));
+ }
+ leftOutputSymbolIdx[i] = index;
+ }
+
+ ImmutableMap rightColumnNamesMap =
+ makeLayoutFromOutputSymbols(node.getRightChild().getOutputSymbols());
+ int[] rightOutputSymbolIdx = new int[node.getRightOutputSymbols().size()];
+ for (int i = 0; i < rightOutputSymbolIdx.length; i++) {
+ Integer index = rightColumnNamesMap.get(node.getRightOutputSymbols().get(i));
+ if (index == null) {
+ throw new IllegalStateException(
+ "Right child of JoinNode doesn't contain RightOutputSymbol "
+ + node.getLeftOutputSymbols().get(i));
+ }
+ rightOutputSymbolIdx[i] = index;
+ }
+
+ // cross join does not need time column
+ if (node.isCrossJoin()) {
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context,
+ node.getPlanNodeId(),
+ SimpleNestedLoopCrossJoinOperator.class.getSimpleName());
+ return new SimpleNestedLoopCrossJoinOperator(
+ operatorContext,
+ leftChild,
+ rightChild,
+ leftOutputSymbolIdx,
+ rightOutputSymbolIdx,
+ dataTypes);
+ }
+
+ semanticCheckForJoin(node);
+
+ JoinNode.AsofJoinClause asofJoinClause = node.getAsofCriteria().orElse(null);
+ int equiSize = node.getCriteria().size();
+ int size = equiSize + (asofJoinClause == null ? 0 : 1);
+ int[] leftJoinKeyPositions = new int[size];
+ for (int i = 0; i < equiSize; i++) {
+ Integer leftJoinKeyPosition = leftColumnNamesMap.get(node.getCriteria().get(i).getLeft());
+ if (leftJoinKeyPosition == null) {
+ throw new IllegalStateException("Left child of JoinNode doesn't contain left join key.");
+ }
+ leftJoinKeyPositions[i] = leftJoinKeyPosition;
+ }
+
+ List joinKeyTypes = new ArrayList<>(size);
+ int[] rightJoinKeyPositions = new int[size];
+ for (int i = 0; i < equiSize; i++) {
+ Integer rightJoinKeyPosition = rightColumnNamesMap.get(node.getCriteria().get(i).getRight());
+ if (rightJoinKeyPosition == null) {
+ throw new IllegalStateException("Right child of JoinNode doesn't contain right join key.");
+ }
+ rightJoinKeyPositions[i] = rightJoinKeyPosition;
+
+ Type leftJoinKeyType =
+ context.getTableTypeProvider().getTableModelType(node.getCriteria().get(i).getLeft());
+ checkIfJoinKeyTypeMatches(
+ leftJoinKeyType,
+ context.getTableTypeProvider().getTableModelType(node.getCriteria().get(i).getRight()));
+ joinKeyTypes.add(leftJoinKeyType);
+ }
+
+ if (asofJoinClause != null) {
+ Integer leftAsofJoinKeyPosition = leftColumnNamesMap.get(asofJoinClause.getLeft());
+ if (leftAsofJoinKeyPosition == null) {
+ throw new IllegalStateException(
+ "Left child of JoinNode doesn't contain left ASOF main join key.");
+ }
+ leftJoinKeyPositions[equiSize] = leftAsofJoinKeyPosition;
+ Integer rightAsofJoinKeyPosition = rightColumnNamesMap.get(asofJoinClause.getRight());
+ if (rightAsofJoinKeyPosition == null) {
+ throw new IllegalStateException(
+ "Right child of JoinNode doesn't contain right ASOF main join key.");
+ }
+ rightJoinKeyPositions[equiSize] = rightAsofJoinKeyPosition;
+
+ if (context.getTableTypeProvider().getTableModelType(asofJoinClause.getLeft()) != TIMESTAMP) {
+ throw new IllegalStateException("Type of left ASOF Join key is not TIMESTAMP");
+ }
+ if (context.getTableTypeProvider().getTableModelType(asofJoinClause.getRight())
+ != TIMESTAMP) {
+ throw new IllegalStateException("Type of right ASOF Join key is not TIMESTAMP");
+ }
+
+ ComparisonExpression.Operator asofOperator = asofJoinClause.getOperator();
+
+ if (requireNonNull(node.getJoinType()) == JoinNode.JoinType.INNER) {
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context,
+ node.getPlanNodeId(),
+ AsofMergeSortInnerJoinOperator.class.getSimpleName());
+ return new AsofMergeSortInnerJoinOperator(
+ operatorContext,
+ leftChild,
+ leftJoinKeyPositions,
+ leftOutputSymbolIdx,
+ rightChild,
+ rightJoinKeyPositions,
+ rightOutputSymbolIdx,
+ JoinKeyComparatorFactory.getAsofComparators(
+ joinKeyTypes,
+ asofOperator == ComparisonExpression.Operator.LESS_THAN_OR_EQUAL
+ || asofOperator == ComparisonExpression.Operator.GREATER_THAN_OR_EQUAL,
+ !asofJoinClause.isOperatorContainsGreater()),
+ dataTypes);
+ } else if (requireNonNull(node.getJoinType()) == JoinNode.JoinType.LEFT) {
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), AsofMergeSortLeftJoinOperator.class.getSimpleName());
+ return new AsofMergeSortLeftJoinOperator(
+ operatorContext,
+ leftChild,
+ leftJoinKeyPositions,
+ leftOutputSymbolIdx,
+ rightChild,
+ rightJoinKeyPositions,
+ rightOutputSymbolIdx,
+ JoinKeyComparatorFactory.getAsofComparators(
+ joinKeyTypes,
+ asofOperator == ComparisonExpression.Operator.LESS_THAN_OR_EQUAL
+ || asofOperator == ComparisonExpression.Operator.GREATER_THAN_OR_EQUAL,
+ !asofJoinClause.isOperatorContainsGreater()),
+ dataTypes);
+ } else {
+ throw new IllegalStateException("Unsupported ASOF join type: " + node.getJoinType());
+ }
+ }
+
+ if (requireNonNull(node.getJoinType()) == JoinNode.JoinType.INNER) {
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), MergeSortInnerJoinOperator.class.getSimpleName());
+ return new MergeSortInnerJoinOperator(
+ operatorContext,
+ leftChild,
+ leftJoinKeyPositions,
+ leftOutputSymbolIdx,
+ rightChild,
+ rightJoinKeyPositions,
+ rightOutputSymbolIdx,
+ JoinKeyComparatorFactory.getComparators(joinKeyTypes, true),
+ dataTypes);
+ } else if (requireNonNull(node.getJoinType()) == JoinNode.JoinType.FULL) {
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), MergeSortFullOuterJoinOperator.class.getSimpleName());
+ return new MergeSortFullOuterJoinOperator(
+ operatorContext,
+ leftChild,
+ leftJoinKeyPositions,
+ leftOutputSymbolIdx,
+ rightChild,
+ rightJoinKeyPositions,
+ rightOutputSymbolIdx,
+ JoinKeyComparatorFactory.getComparators(joinKeyTypes, true),
+ dataTypes,
+ joinKeyTypes.stream().map(this::buildUpdateLastRowFunction).collect(Collectors.toList()));
+ } else if (requireNonNull(node.getJoinType()) == JoinNode.JoinType.LEFT) {
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), MergeSortLeftJoinOperator.class.getSimpleName());
+ return new MergeSortLeftJoinOperator(
+ operatorContext,
+ leftChild,
+ leftJoinKeyPositions,
+ leftOutputSymbolIdx,
+ rightChild,
+ rightJoinKeyPositions,
+ rightOutputSymbolIdx,
+ JoinKeyComparatorFactory.getComparators(joinKeyTypes, true),
+ dataTypes);
+ }
+
+ throw new IllegalStateException("Unsupported join type: " + node.getJoinType());
+ }
+
+ protected void semanticCheckForJoin(JoinNode node) {
+ try {
+ checkArgument(
+ !node.getFilter().isPresent() || node.getFilter().get().equals(TRUE_LITERAL),
+ String.format(
+ "Filter is not supported in %s. Filter is %s.",
+ node.getJoinType(), node.getFilter().map(Expression::toString).orElse("null")));
+ checkArgument(
+ !node.getCriteria().isEmpty() || node.getAsofCriteria().isPresent(),
+ String.format("%s must have join keys.", node.getJoinType()));
+ } catch (IllegalArgumentException e) {
+ throw new SemanticException(e.getMessage());
+ }
+ }
+
+ protected BiFunction buildUpdateLastRowFunction(Type joinKeyType) {
+ switch (joinKeyType.getTypeEnum()) {
+ case INT32:
+ return (inputColumn, rowIndex) ->
+ new IntColumn(
+ 1, Optional.empty(), new int[] {inputColumn.getInt(rowIndex)}, TSDataType.INT32);
+ case DATE:
+ return (inputColumn, rowIndex) ->
+ new IntColumn(
+ 1, Optional.empty(), new int[] {inputColumn.getInt(rowIndex)}, TSDataType.DATE);
+ case INT64:
+ case TIMESTAMP:
+ return (inputColumn, rowIndex) ->
+ new LongColumn(1, Optional.empty(), new long[] {inputColumn.getLong(rowIndex)});
+ case FLOAT:
+ return (inputColumn, rowIndex) ->
+ new FloatColumn(1, Optional.empty(), new float[] {inputColumn.getFloat(rowIndex)});
+ case DOUBLE:
+ return (inputColumn, rowIndex) ->
+ new DoubleColumn(1, Optional.empty(), new double[] {inputColumn.getDouble(rowIndex)});
+ case BOOLEAN:
+ return (inputColumn, rowIndex) ->
+ new BooleanColumn(
+ 1, Optional.empty(), new boolean[] {inputColumn.getBoolean(rowIndex)});
+ case STRING:
+ case TEXT:
+ case BLOB:
+ return (inputColumn, rowIndex) ->
+ new BinaryColumn(1, Optional.empty(), new Binary[] {inputColumn.getBinary(rowIndex)});
+ default:
+ throw new UnsupportedOperationException("Unsupported data type: " + joinKeyType);
+ }
+ }
+
+ @Override
+ public Operator visitSemiJoin(SemiJoinNode node, C context) {
+ List dataTypes = getOutputColumnTypes(node, context.getTableTypeProvider());
+
+ Operator leftChild = node.getLeftChild().accept(this, context);
+ Operator rightChild = node.getRightChild().accept(this, context);
+
+ ImmutableMap sourceColumnNamesMap =
+ makeLayoutFromOutputSymbols(node.getSource().getOutputSymbols());
+ List sourceOutputSymbols = node.getSource().getOutputSymbols();
+ int[] sourceOutputSymbolIdx = new int[node.getSource().getOutputSymbols().size()];
+ for (int i = 0; i < sourceOutputSymbolIdx.length; i++) {
+ Integer index = sourceColumnNamesMap.get(sourceOutputSymbols.get(i));
+ checkNotNull(index, "Source of SemiJoinNode doesn't contain sourceOutputSymbol.");
+ sourceOutputSymbolIdx[i] = index;
+ }
+
+ ImmutableMap filteringSourceColumnNamesMap =
+ makeLayoutFromOutputSymbols(node.getRightChild().getOutputSymbols());
+
+ Integer sourceJoinKeyPosition = sourceColumnNamesMap.get(node.getSourceJoinSymbol());
+ checkNotNull(sourceJoinKeyPosition, "Source of SemiJoinNode doesn't contain sourceJoinSymbol.");
+
+ Integer filteringSourceJoinKeyPosition =
+ filteringSourceColumnNamesMap.get(node.getFilteringSourceJoinSymbol());
+ checkNotNull(
+ filteringSourceJoinKeyPosition,
+ "FilteringSource of SemiJoinNode doesn't contain filteringSourceJoinSymbol.");
+
+ Type sourceJoinKeyType =
+ context.getTableTypeProvider().getTableModelType(node.getSourceJoinSymbol());
+
+ checkIfJoinKeyTypeMatches(
+ sourceJoinKeyType,
+ context.getTableTypeProvider().getTableModelType(node.getFilteringSourceJoinSymbol()));
+
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), MergeSortSemiJoinOperator.class.getSimpleName());
+ return new MergeSortSemiJoinOperator(
+ operatorContext,
+ leftChild,
+ sourceJoinKeyPosition,
+ sourceOutputSymbolIdx,
+ rightChild,
+ filteringSourceJoinKeyPosition,
+ JoinKeyComparatorFactory.getComparator(sourceJoinKeyType, true),
+ dataTypes);
+ }
+
+ protected void checkIfJoinKeyTypeMatches(Type leftJoinKeyType, Type rightJoinKeyType) {
+ if (leftJoinKeyType != rightJoinKeyType) {
+ throw new SemanticException(
+ "Join key type mismatch. Left join key type: "
+ + leftJoinKeyType
+ + ", right join key type: "
+ + rightJoinKeyType);
+ }
+ }
+
+ @Override
+ public Operator visitEnforceSingleRow(EnforceSingleRowNode node, C context) {
+ Operator child = node.getChild().accept(this, context);
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), EnforceSingleRowOperator.class.getSimpleName());
+
+ return new EnforceSingleRowOperator(operatorContext, child);
+ }
+
+ @Override
+ public Operator visitAssignUniqueId(AssignUniqueId node, C context) {
+ Operator child = node.getChild().accept(this, context);
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), EnforceSingleRowOperator.class.getSimpleName());
+
+ return new AssignUniqueIdOperator(operatorContext, child);
+ }
+
+ @Override
+ public Operator visitAggregation(AggregationNode node, C context) {
+
+ Operator child = node.getChild().accept(this, context);
+
+ if (node.getGroupingKeys().isEmpty()) {
+ return planGlobalAggregation(node, child, context.getTableTypeProvider(), context);
+ }
+
+ return planGroupByAggregation(node, child, context.getTableTypeProvider(), context);
+ }
+
+ private Operator planGlobalAggregation(
+ AggregationNode node, Operator child, ITableTypeProvider typeProvider, C context) {
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), AggregationOperator.class.getSimpleName());
+ Map aggregationMap = node.getAggregations();
+ ImmutableList.Builder aggregatorBuilder = new ImmutableList.Builder<>();
+ Map childLayout =
+ makeLayoutFromOutputSymbols(node.getChild().getOutputSymbols());
+
+ node.getOutputSymbols()
+ .forEach(
+ symbol ->
+ aggregatorBuilder.add(
+ buildAggregator(
+ childLayout,
+ symbol,
+ aggregationMap.get(symbol),
+ node.getStep(),
+ typeProvider,
+ true,
+ false,
+ null,
+ Collections.emptySet())));
+ return new AggregationOperator(operatorContext, child, aggregatorBuilder.build());
+ }
+
+ // timeColumnName and measurementColumnNames will only be set for AggTableScan.
+ protected TableAggregator buildAggregator(
+ Map childLayout,
+ Symbol symbol,
+ AggregationNode.Aggregation aggregation,
+ AggregationNode.Step step,
+ ITableTypeProvider typeProvider,
+ boolean scanAscending,
+ boolean isAggTableScan,
+ String timeColumnName,
+ Set measurementColumnNames) {
+ List argumentChannels = new ArrayList<>();
+ for (Expression argument : aggregation.getArguments()) {
+ Symbol argumentSymbol = Symbol.from(argument);
+ argumentChannels.add(childLayout.get(argumentSymbol));
+ }
+
+ String functionName = aggregation.getResolvedFunction().getSignature().getName();
+ List originalArgumentTypes =
+ aggregation.getResolvedFunction().getSignature().getArgumentTypes().stream()
+ .map(InternalTypeManager::getTSDataType)
+ .collect(Collectors.toList());
+ TableAccumulator accumulator =
+ createAccumulator(
+ functionName,
+ getAggregationTypeByFuncName(functionName),
+ originalArgumentTypes,
+ aggregation.getArguments(),
+ Collections.emptyMap(),
+ scanAscending,
+ isAggTableScan,
+ timeColumnName,
+ measurementColumnNames,
+ aggregation.isDistinct());
+
+ OptionalInt maskChannel = OptionalInt.empty();
+ if (aggregation.hasMask()) {
+ maskChannel = OptionalInt.of(childLayout.get(aggregation.getMask().get()));
+ }
+
+ return new TableAggregator(
+ accumulator,
+ step,
+ getTSDataType(typeProvider.getTableModelType(symbol)),
+ argumentChannels,
+ maskChannel);
+ }
+
+ protected Operator planGroupByAggregation(
+ AggregationNode node, Operator child, ITableTypeProvider typeProvider, C context) {
+ Map childLayout =
+ makeLayoutFromOutputSymbols(node.getChild().getOutputSymbols());
+
+ List groupByChannels = getChannelsForSymbols(node.getGroupingKeys(), childLayout);
+ List groupByTypes =
+ node.getGroupingKeys().stream()
+ .map(typeProvider::getTableModelType)
+ .collect(toImmutableList());
+
+ if (node.isStreamable()) {
+ if (groupByTypes.size() == node.getPreGroupedSymbols().size()) {
+ ImmutableList.Builder aggregatorBuilder = new ImmutableList.Builder<>();
+ node.getAggregations()
+ .forEach(
+ (k, v) ->
+ aggregatorBuilder.add(
+ buildAggregator(
+ childLayout,
+ k,
+ v,
+ node.getStep(),
+ typeProvider,
+ true,
+ false,
+ null,
+ Collections.emptySet())));
+
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), StreamingAggregationOperator.class.getSimpleName());
+ return new StreamingAggregationOperator(
+ operatorContext,
+ child,
+ groupByTypes,
+ groupByChannels,
+ genGroupKeyComparator(groupByTypes, groupByChannels),
+ aggregatorBuilder.build(),
+ Long.MAX_VALUE,
+ false,
+ Long.MAX_VALUE);
+ }
+
+ ImmutableList.Builder aggregatorBuilder = new ImmutableList.Builder<>();
+ node.getAggregations()
+ .forEach(
+ (k, v) ->
+ aggregatorBuilder.add(
+ buildGroupByAggregator(childLayout, k, v, node.getStep(), typeProvider)));
+
+ Set preGroupedKeys = ImmutableSet.copyOf(node.getPreGroupedSymbols());
+ List groupingKeys = node.getGroupingKeys();
+ ImmutableList.Builder preGroupedTypesBuilder = new ImmutableList.Builder<>();
+ ImmutableList.Builder preGroupedChannelsBuilder = new ImmutableList.Builder<>();
+ ImmutableList.Builder preGroupedIndexInResultBuilder = new ImmutableList.Builder<>();
+ ImmutableList.Builder unPreGroupedTypesBuilder = new ImmutableList.Builder<>();
+ ImmutableList.Builder unPreGroupedChannelsBuilder = new ImmutableList.Builder<>();
+ ImmutableList.Builder unPreGroupedIndexInResultBuilder =
+ new ImmutableList.Builder<>();
+ for (int i = 0; i < groupByTypes.size(); i++) {
+ if (preGroupedKeys.contains(groupingKeys.get(i))) {
+ preGroupedTypesBuilder.add(groupByTypes.get(i));
+ preGroupedChannelsBuilder.add(groupByChannels.get(i));
+ preGroupedIndexInResultBuilder.add(i);
+ } else {
+ unPreGroupedTypesBuilder.add(groupByTypes.get(i));
+ unPreGroupedChannelsBuilder.add(groupByChannels.get(i));
+ unPreGroupedIndexInResultBuilder.add(i);
+ }
+ }
+
+ List preGroupedChannels = preGroupedChannelsBuilder.build();
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context,
+ node.getPlanNodeId(),
+ StreamingHashAggregationOperator.class.getSimpleName());
+ return new StreamingHashAggregationOperator(
+ operatorContext,
+ child,
+ preGroupedChannels,
+ preGroupedIndexInResultBuilder.build(),
+ unPreGroupedTypesBuilder.build(),
+ unPreGroupedChannelsBuilder.build(),
+ unPreGroupedIndexInResultBuilder.build(),
+ genGroupKeyComparator(preGroupedTypesBuilder.build(), preGroupedChannels),
+ aggregatorBuilder.build(),
+ node.getStep(),
+ DEFAULT_GROUP_NUMBER,
+ Long.MAX_VALUE,
+ false,
+ Long.MAX_VALUE);
+ }
+
+ ImmutableList.Builder aggregatorBuilder = new ImmutableList.Builder<>();
+ node.getAggregations()
+ .forEach(
+ (k, v) ->
+ aggregatorBuilder.add(
+ buildGroupByAggregator(childLayout, k, v, node.getStep(), typeProvider)));
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), HashAggregationOperator.class.getSimpleName());
+
+ return new HashAggregationOperator(
+ operatorContext,
+ child,
+ groupByTypes,
+ groupByChannels,
+ aggregatorBuilder.build(),
+ node.getStep(),
+ DEFAULT_GROUP_NUMBER,
+ Long.MAX_VALUE,
+ false,
+ Long.MAX_VALUE);
+ }
+
+ protected Comparator genGroupKeyComparator(
+ List groupTypes, List groupByChannels) {
+ return getComparatorForTable(
+ // SortOrder is not sensitive here, the comparator is just used to judge equality.
+ groupTypes.stream().map(k -> ASC_NULLS_LAST).collect(Collectors.toList()),
+ groupByChannels,
+ groupTypes.stream().map(InternalTypeManager::getTSDataType).collect(Collectors.toList()));
+ }
+
+ protected static List getChannelsForSymbols(
+ List symbols, Map layout) {
+ ImmutableList.Builder builder = ImmutableList.builder();
+ for (Symbol symbol : symbols) {
+ builder.add(layout.get(symbol));
+ }
+ return builder.build();
+ }
+
+ protected GroupedAggregator buildGroupByAggregator(
+ Map childLayout,
+ Symbol symbol,
+ AggregationNode.Aggregation aggregation,
+ AggregationNode.Step step,
+ ITableTypeProvider typeProvider) {
+ List argumentChannels = new ArrayList<>();
+ for (Expression argument : aggregation.getArguments()) {
+ Symbol argumentSymbol = Symbol.from(argument);
+ argumentChannels.add(childLayout.get(argumentSymbol));
+ }
+
+ String functionName = aggregation.getResolvedFunction().getSignature().getName();
+ List originalArgumentTypes =
+ aggregation.getResolvedFunction().getSignature().getArgumentTypes().stream()
+ .map(InternalTypeManager::getTSDataType)
+ .collect(Collectors.toList());
+ GroupedAccumulator accumulator =
+ createGroupedAccumulator(
+ functionName,
+ getAggregationTypeByFuncName(functionName),
+ originalArgumentTypes,
+ Collections.emptyList(),
+ Collections.emptyMap(),
+ true,
+ aggregation.isDistinct());
+
+ OptionalInt maskChannel = OptionalInt.empty();
+ if (aggregation.hasMask()) {
+ maskChannel = OptionalInt.of(childLayout.get(aggregation.getMask().get()));
+ }
+
+ return new GroupedAggregator(
+ accumulator,
+ step,
+ getTSDataType(typeProvider.getTableModelType(symbol)),
+ argumentChannels,
+ maskChannel);
+ }
+
+ @Override
+ public Operator visitTableFunctionProcessor(TableFunctionProcessorNode node, C context) {
+ TableFunction tableFunction = metadata.getTableFunction(node.getName());
+ TableFunctionProcessorProvider processorProvider =
+ tableFunction.getProcessorProvider(node.getTableFunctionHandle());
+ if (node.getChildren().isEmpty()) {
+ List outputDataTypes =
+ node.getOutputSymbols().stream()
+ .map(context.getTableTypeProvider()::getTableModelType)
+ .map(InternalTypeManager::getTSDataType)
+ .collect(Collectors.toList());
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), TableFunctionLeafOperator.class.getSimpleName());
+ return new TableFunctionLeafOperator(operatorContext, processorProvider, outputDataTypes);
+ } else {
+ Operator operator = node.getChild().accept(this, context);
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), TableFunctionOperator.class.getSimpleName());
+
+ List inputDataTypes =
+ node.getChild().getOutputSymbols().stream()
+ .map(context.getTableTypeProvider()::getTableModelType)
+ .map(InternalTypeManager::getTSDataType)
+ .collect(Collectors.toList());
+
+ List outputDataTypes =
+ node.getOutputSymbols().stream()
+ .map(context.getTableTypeProvider()::getTableModelType)
+ .map(InternalTypeManager::getTSDataType)
+ .collect(Collectors.toList());
+
+ int properChannelCount = node.getProperOutputs().size();
+ Optional passThroughSpecification =
+ node.getPassThroughSpecification();
+
+ Map childLayout =
+ makeLayoutFromOutputSymbols(node.getChild().getOutputSymbols());
+ List requiredChannels =
+ getChannelsForSymbols(node.getRequiredSymbols(), childLayout);
+ List passThroughChannels =
+ passThroughSpecification
+ .map(
+ passThrough ->
+ getChannelsForSymbols(
+ passThrough.getColumns().stream()
+ .map(TableFunctionNode.PassThroughColumn::getSymbol)
+ .collect(Collectors.toList()),
+ childLayout))
+ .orElse(Collections.emptyList());
+ List partitionChannels;
+ if (node.getDataOrganizationSpecification().isPresent()) {
+ partitionChannels =
+ getChannelsForSymbols(
+ node.getDataOrganizationSpecification().get().getPartitionBy(), childLayout);
+ } else {
+ partitionChannels = Collections.emptyList();
+ }
+ return new TableFunctionOperator(
+ operatorContext,
+ processorProvider,
+ operator,
+ inputDataTypes,
+ outputDataTypes,
+ properChannelCount,
+ requiredChannels,
+ passThroughChannels,
+ passThroughSpecification
+ .map(TableFunctionNode.PassThroughSpecification::isDeclaredAsPassThrough)
+ .orElse(false),
+ partitionChannels,
+ node.isRequireRecordSnapshot());
+ }
+ }
+
+ private PatternAggregator buildPatternAggregator(
+ ResolvedFunction resolvedFunction,
+ List> arguments,
+ List argumentChannels,
+ PatternAggregationTracker patternAggregationTracker) {
+ String functionName = resolvedFunction.getSignature().getName();
+ List originalArgumentTypes =
+ resolvedFunction.getSignature().getArgumentTypes().stream()
+ .map(InternalTypeManager::getTSDataType)
+ .collect(Collectors.toList());
+
+ TableAccumulator accumulator =
+ createBuiltinAccumulator(getAggregationTypeByFuncName(functionName), originalArgumentTypes);
+
+ BoundSignature signature = resolvedFunction.getSignature();
+
+ return new PatternAggregator(
+ signature, accumulator, argumentChannels, patternAggregationTracker);
+ }
+
+ @Override
+ public Operator visitPatternRecognition(PatternRecognitionNode node, C context) {
+ CommonOperatorContext operatorContext =
+ addOperatorContext(
+ context, node.getPlanNodeId(), PatternRecognitionOperator.class.getSimpleName());
+
+ Operator child = node.getChild().accept(this, context);
+
+ Map childLayout =
+ makeLayoutFromOutputSymbols(node.getChild().getOutputSymbols());
+
+ List partitionBySymbols = node.getPartitionBy();
+ List partitionChannels =
+ ImmutableList.copyOf(getChannelsForSymbols(partitionBySymbols, childLayout));
+
+ List sortChannels = ImmutableList.of();
+ List sortOrder = ImmutableList.of();
+
+ if (node.getOrderingScheme().isPresent()) {
+ OrderingScheme orderingScheme = node.getOrderingScheme().get();
+ sortChannels = getChannelsForSymbols(orderingScheme.getOrderBy(), childLayout);
+ sortOrder = orderingScheme.getOrderingList();
+ }
+
+ // The output order for pattern recognition operation is defined as follows:
+ // - for ONE ROW PER MATCH: partition by symbols, then measures,
+ // - for ALL ROWS PER MATCH: partition by symbols, order by symbols, measures, remaining input
+ // symbols.
+
+ // all output column types of the input table
+ List inputDataTypes =
+ getOutputColumnTypes(node.getChild(), context.getTableTypeProvider());
+
+ // input channels to be passed directly to output, excluding MEASURES columns
+ ImmutableList.Builder outputChannels = ImmutableList.builder();
+ // output dataTypes, used to construct the output TsBlock, including MEASURES columns
+ ImmutableList.Builder outputDataTypes = ImmutableList.builder();
+
+ if (node.getRowsPerMatch() == ONE) {
+ // ONE ROW PER MATCH: partition columns, MEASURES
+
+ // add all partition columns
+ outputChannels.addAll(partitionChannels);
+ for (int i = 0; i < partitionBySymbols.size(); i++) {
+ Symbol symbol = partitionBySymbols.get(i);
+ // obtain the absolute index of the symbol in the base table through `childLayout`
+ outputDataTypes.add(inputDataTypes.get(childLayout.get(symbol)));
+ }
+ } else {
+ // ALL ROWS PER MATCH: all input columns, MEASURES
+
+ outputChannels.addAll(
+ IntStream.range(0, inputDataTypes.size()).boxed().collect(toImmutableList()));
+ outputDataTypes.addAll(inputDataTypes);
+ }
+
+ // add MEASURES columns
+ for (Map.Entry measure : node.getMeasures().entrySet()) {
+ outputDataTypes.add(getTSDataType(measure.getValue().getType()));
+ }
+
+ // prepare structures specific to PatternRecognitionNode
+ // 1. establish a two-way mapping of IrLabels to `int`
+ List primaryLabels = ImmutableList.copyOf(node.getVariableDefinitions().keySet());
+ ImmutableList.Builder labelNamesBuilder = ImmutableList.builder();
+ ImmutableMap.Builder mappingBuilder = ImmutableMap.builder();
+ for (int i = 0; i < primaryLabels.size(); i++) {
+ IrLabel label = primaryLabels.get(i);
+ labelNamesBuilder.add(label.getName());
+ mappingBuilder.put(label, i);
+ }
+ Map mapping = mappingBuilder.buildOrThrow();
+ List labelNames = labelNamesBuilder.build();
+
+ // 2. rewrite pattern to program
+ Program program = IrRowPatternToProgramRewriter.rewrite(node.getPattern(), mapping);
+
+ // 3. DEFINE: prepare patternVariableComputation (PatternVariableRecognizer is to be
+ // instantiated once per partition)
+
+ // during pattern matching, each thread will have a list of aggregations necessary for label
+ // evaluations.
+ // the list of aggregations for a thread will be produced at thread creation time from this
+ // supplier list, respecting the order.
+ // pointers in LabelEvaluator and ThreadEquivalence will access aggregations by position in
+ // list.
+ int matchAggregationIndex = 0;
+ ImmutableList.Builder variableRecognizerAggregatorBuilder =
+ ImmutableList.builder();
+ List variableRecognizerAggregators = ImmutableList.of();
+
+ ImmutableList.Builder evaluationsBuilder =
+ ImmutableList.builder();
+
+ for (Map.Entry entry :
+ node.getVariableDefinitions().entrySet()) {
+ String variableName = entry.getKey().getName();
+ ExpressionAndValuePointers expressionAndValuePointers = entry.getValue();
+
+ // convert the `ValuePointer` in the `Assignment` to `PhysicalValueAccessor`
+ List valueAccessors = new ArrayList<>();
+ for (ExpressionAndValuePointers.Assignment assignment :
+ expressionAndValuePointers.getAssignments()) {
+ ValuePointer pointer = assignment.getValuePointer();
+ if (pointer instanceof MatchNumberValuePointer) {
+ valueAccessors.add(
+ new PhysicalValuePointer(MATCH_NUMBER, INT64, LogicalIndexNavigation.NO_OP));
+ } else if (pointer instanceof ClassifierValuePointer) {
+ ClassifierValuePointer classifierPointer = (ClassifierValuePointer) pointer;
+ valueAccessors.add(
+ new PhysicalValuePointer(
+ CLASSIFIER,
+ STRING,
+ new LogicalIndexNavigation(classifierPointer.getLogicalIndexPointer(), mapping)));
+ } else if (pointer instanceof ScalarValuePointer) {
+ ScalarValuePointer scalarPointer = (ScalarValuePointer) pointer;
+ valueAccessors.add(
+ new PhysicalValuePointer(
+ getOnlyElement(
+ getChannelsForSymbols(
+ ImmutableList.of(scalarPointer.getInputSymbol()), childLayout)),
+ context.getTableTypeProvider().getTableModelType(scalarPointer.getInputSymbol()),
+ new LogicalIndexNavigation(scalarPointer.getLogicalIndexPointer(), mapping)));
+ } else if (pointer instanceof AggregationValuePointer) {
+ AggregationValuePointer aggregationPointer = (AggregationValuePointer) pointer;
+
+ ResolvedFunction resolvedFunction = aggregationPointer.getFunction();
+
+ ImmutableList.Builder> builder = ImmutableList.builder();
+ List signatureTypes = resolvedFunction.getSignature().getArgumentTypes();
+ for (int i = 0; i < aggregationPointer.getArguments().size(); i++) {
+ builder.add(
+ new AbstractMap.SimpleEntry<>(
+ aggregationPointer.getArguments().get(i), signatureTypes.get(i)));
+ }
+ List> arguments = builder.build();
+
+ List valueChannels = new ArrayList<>();
+
+ for (Map.Entry argumentWithType : arguments) {
+ Expression argument = argumentWithType.getKey();
+ valueChannels.add(childLayout.get(Symbol.from(argument)));
+ }
+
+ AggregationLabelSet labelSet = aggregationPointer.getSetDescriptor();
+ Set labels =
+ labelSet.getLabels().stream().map(mapping::get).collect(Collectors.toSet());
+ PatternAggregationTracker patternAggregationTracker =
+ new PatternAggregationTracker(
+ labels, aggregationPointer.getSetDescriptor().isRunning());
+
+ PatternAggregator variableRecognizerAggregator =
+ buildPatternAggregator(
+ resolvedFunction, arguments, valueChannels, patternAggregationTracker);
+
+ variableRecognizerAggregatorBuilder.add(variableRecognizerAggregator);
+
+ valueAccessors.add(new PhysicalAggregationPointer(matchAggregationIndex));
+ matchAggregationIndex++;
+ }
+ }
+
+ variableRecognizerAggregators = variableRecognizerAggregatorBuilder.build();
+
+ // transform the symbolic expression tree in the logical planning stage into a parametric
+ // expression tree
+ Computation computation = Computation.ComputationParser.parse(expressionAndValuePointers);
+
+ // construct a `PatternVariableComputation` object, where valueAccessors is a parameter list
+ // and computation is a parametric expression tree, encapsulating the computation logic
+ PatternVariableRecognizer.PatternVariableComputation patternVariableComputation =
+ new PatternVariableRecognizer.PatternVariableComputation(
+ valueAccessors, computation, ImmutableList.of(), labelNames);
+
+ evaluationsBuilder.add(patternVariableComputation);
+ }
+
+ // 4. MEASURES: prepare measures computations
+ ImmutableList.Builder measureComputationsBuilder =
+ ImmutableList.builder();
+
+ matchAggregationIndex = 0;
+ ImmutableList.Builder measurePatternAggregatorBuilder =
+ ImmutableList.builder();
+ List measurePatternAggregators = ImmutableList.of();
+
+ for (Measure measure : node.getMeasures().values()) {
+ ExpressionAndValuePointers expressionAndValuePointers =
+ measure.getExpressionAndValuePointers();
+
+ // convert the `ValuePointer` in the `Assignment` to `PhysicalValueAccessor`
+ List valueAccessors = new ArrayList<>();
+ for (ExpressionAndValuePointers.Assignment assignment :
+ expressionAndValuePointers.getAssignments()) {
+ ValuePointer pointer = assignment.getValuePointer();
+ if (pointer instanceof MatchNumberValuePointer) {
+ valueAccessors.add(
+ new PhysicalValuePointer(MATCH_NUMBER, INT64, LogicalIndexNavigation.NO_OP));
+ } else if (pointer instanceof ClassifierValuePointer) {
+ ClassifierValuePointer classifierPointer = (ClassifierValuePointer) pointer;
+ valueAccessors.add(
+ new PhysicalValuePointer(
+ CLASSIFIER,
+ STRING,
+ new LogicalIndexNavigation(classifierPointer.getLogicalIndexPointer(), mapping)));
+ } else if (pointer instanceof ScalarValuePointer) {
+ ScalarValuePointer scalarPointer = (ScalarValuePointer) pointer;
+ valueAccessors.add(
+ new PhysicalValuePointer(
+ getOnlyElement(
+ getChannelsForSymbols(
+ ImmutableList.of(scalarPointer.getInputSymbol()), childLayout)),
+ context.getTableTypeProvider().getTableModelType(scalarPointer.getInputSymbol()),
+ new LogicalIndexNavigation(scalarPointer.getLogicalIndexPointer(), mapping)));
+ } else if (pointer instanceof AggregationValuePointer) {
+ AggregationValuePointer aggregationPointer = (AggregationValuePointer) pointer;
+
+ ResolvedFunction resolvedFunction = aggregationPointer.getFunction();
+
+ ImmutableList.Builder> builder = ImmutableList.builder();
+ List