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

jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new b0384095cb [IOTDB-4863] Fix a bug in memory estimation in 
DeviceViewNode
b0384095cb is described below

commit b0384095cb1b6810e5320b2c529c994a8205a38b
Author: Jackie Tien <[email protected]>
AuthorDate: Sat Nov 19 09:19:40 2022 +0800

    [IOTDB-4863] Fix a bug in memory estimation in DeviceViewNode
---
 .../db/mpp/execution/operator/process/DeviceViewOperator.java    | 6 +++---
 .../iotdb/db/mpp/execution/operator/OperatorMemoryTest.java      | 9 ++++++---
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git 
a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/DeviceViewOperator.java
 
b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/DeviceViewOperator.java
index 728da7e7db..b9d6274ac0 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/DeviceViewOperator.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/DeviceViewOperator.java
@@ -174,10 +174,10 @@ public class DeviceViewOperator implements 
ProcessOperator {
 
   @Override
   public long calculateRetainedSizeAfterCallingNext() {
-    long sum = 0;
+    long max = 0;
     for (Operator operator : deviceOperators) {
-      sum += operator.calculateRetainedSizeAfterCallingNext();
+      max = Math.max(max, operator.calculateRetainedSizeAfterCallingNext());
     }
-    return sum;
+    return max;
   }
 }
diff --git 
a/server/src/test/java/org/apache/iotdb/db/mpp/execution/operator/OperatorMemoryTest.java
 
b/server/src/test/java/org/apache/iotdb/db/mpp/execution/operator/OperatorMemoryTest.java
index 9a3f34b3a1..9832d27531 100644
--- 
a/server/src/test/java/org/apache/iotdb/db/mpp/execution/operator/OperatorMemoryTest.java
+++ 
b/server/src/test/java/org/apache/iotdb/db/mpp/execution/operator/OperatorMemoryTest.java
@@ -583,13 +583,16 @@ public class OperatorMemoryTest {
       Mockito.when(child.calculateMaxPeekMemory()).thenReturn(1024L);
       Mockito.when(child.calculateMaxReturnSize()).thenReturn(1024L);
       
Mockito.when(child.calculateRetainedSizeAfterCallingNext()).thenReturn(1024L);
-      expectedMaxPeekMemory += 1024L;
       childrenMaxPeekMemory = Math.max(childrenMaxPeekMemory, 
child.calculateMaxPeekMemory());
-      expectedRetainedSizeAfterCallingNext += 1024L;
+      expectedRetainedSizeAfterCallingNext =
+          Math.max(
+              expectedRetainedSizeAfterCallingNext, 
child.calculateRetainedSizeAfterCallingNext());
       children.add(child);
     }
 
-    expectedMaxPeekMemory = Math.max(expectedMaxPeekMemory, 
childrenMaxPeekMemory);
+    expectedMaxPeekMemory =
+        Math.max(expectedMaxPeekMemory, childrenMaxPeekMemory)
+            + expectedRetainedSizeAfterCallingNext;
 
     DeviceViewOperator deviceViewOperator =
         new DeviceViewOperator(

Reply via email to