You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2025/05/21 03:16:02 UTC

(iotdb) branch master updated: Pipe: refine memory cost estimation of Binary types for more precise memory control (#15540)

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

rong 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 069354f76b7 Pipe: refine memory cost estimation of Binary types for more precise memory control (#15540)
069354f76b7 is described below

commit 069354f76b7d0307072667161f936c3505b623a6
Author: Zikun Ma <55...@users.noreply.github.com>
AuthorDate: Wed May 21 11:15:56 2025 +0800

    Pipe: refine memory cost estimation of Binary types for more precise memory control (#15540)
---
 .../db/pipe/resource/memory/PipeMemoryWeightUtil.java  | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryWeightUtil.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryWeightUtil.java
index 1521f425f16..7b3705cf2a5 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryWeightUtil.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryWeightUtil.java
@@ -110,9 +110,10 @@ public class PipeMemoryWeightUtil {
 
         if (tsDataType.isBinary()) {
           final Binary binary = field.getBinaryV();
-          totalSizeInBytes += binary == null ? 0 : binary.getLength();
+          totalSizeInBytes += binary == null ? 8 : binary.ramBytesUsed();
         } else {
-          totalSizeInBytes += tsDataType.getDataTypeSize();
+          totalSizeInBytes +=
+              roundUpToMultiple(TsPrimitiveType.getByType(tsDataType).getSize() + 8, 8);
         }
       }
     }
@@ -146,18 +147,18 @@ public class PipeMemoryWeightUtil {
 
           if (primitiveType.getDataType().isBinary()) {
             final Binary binary = primitiveType.getBinary();
-            totalSizeInBytes += binary == null ? 0 : binary.getLength();
+            totalSizeInBytes += binary == null ? 8 : binary.ramBytesUsed();
           } else {
-            totalSizeInBytes += primitiveType.getDataType().getDataTypeSize();
+            totalSizeInBytes += roundUpToMultiple(primitiveType.getSize() + 8, 8);
           }
         }
       } else {
         schemaCount = 1;
         if (type.isBinary()) {
           final Binary binary = batchData.getBinary();
-          totalSizeInBytes += binary == null ? 0 : binary.getLength();
+          totalSizeInBytes += binary == null ? 8 : binary.ramBytesUsed();
         } else {
-          totalSizeInBytes += type.getDataTypeSize();
+          totalSizeInBytes += roundUpToMultiple(TsPrimitiveType.getByType(type).getSize() + 8, 8);
         }
       }
     }
@@ -240,11 +241,10 @@ public class PipeMemoryWeightUtil {
             continue;
           }
           for (Binary value : values) {
-            totalSizeInBytes +=
-                value == null ? 0 : (value.getLength() == -1 ? 0 : value.getLength());
+            totalSizeInBytes += value == null ? 8 : value.ramBytesUsed();
           }
         } else {
-          totalSizeInBytes += (long) timestamps.length * tsDataType.getDataTypeSize();
+          totalSizeInBytes += (long) tablet.getMaxRowNumber() * tsDataType.getDataTypeSize();
         }
       }
     }