This is an automated email from the ASF dual-hosted git repository.

hui pushed a commit to branch lmh/AggOpMemoryControl
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 99c77b97e600239b5c0b194b255e44955af8262d
Author: Minghui Liu <[email protected]>
AuthorDate: Wed Aug 10 11:29:21 2022 +0800

    memory control for RawDataAggregationOperator
---
 .../operator/process/RawDataAggregationOperator.java      | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git 
a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/RawDataAggregationOperator.java
 
b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/RawDataAggregationOperator.java
index 88fb5fe20a..1cd922bb46 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/RawDataAggregationOperator.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/RawDataAggregationOperator.java
@@ -23,12 +23,14 @@ import org.apache.iotdb.db.mpp.aggregation.Aggregator;
 import org.apache.iotdb.db.mpp.execution.operator.Operator;
 import org.apache.iotdb.db.mpp.execution.operator.OperatorContext;
 import 
org.apache.iotdb.db.mpp.plan.planner.plan.parameter.GroupByTimeParameter;
+import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
 import org.apache.iotdb.tsfile.read.common.block.TsBlock;
 import org.apache.iotdb.tsfile.utils.Pair;
 
 import java.util.List;
 
 import static 
org.apache.iotdb.db.mpp.execution.operator.AggregationUtil.calculateAggregationFromRawData;
+import static 
org.apache.iotdb.tsfile.read.common.block.TsBlockBuilderStatus.DEFAULT_MAX_TSBLOCK_SIZE_IN_BYTES;
 
 /**
  * RawDataAggregationOperator is used to process raw data tsBlock input 
calculating using value
@@ -80,4 +82,17 @@ public class RawDataAggregationOperator extends 
SingleInputAggregationOperator {
     inputTsBlock = calcResult.getRight();
     return calcResult.getLeft();
   }
+
+  @Override
+  public long calculateMaxPeekMemory() {
+    return calculateMaxReturnSize() + child.calculateMaxReturnSize();
+  }
+
+  @Override
+  public long calculateMaxReturnSize() {
+    // time + all value columns
+    return (1L + inputTsBlock.getValueColumnCount())
+            * TSFileDescriptor.getInstance().getConfig().getPageSizeInByte()
+        + DEFAULT_MAX_TSBLOCK_SIZE_IN_BYTES;
+  }
 }

Reply via email to