You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tsfile.apache.org by ja...@apache.org on 2025/01/21 02:56:10 UTC
(tsfile) 02/02: Optimize retained memory size calculation for getRegion method of BinaryColumn
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch TuneBinaryColumnMemory
in repository https://gitbox.apache.org/repos/asf/tsfile.git
commit beace6cbd2525336afd179a1c72d0b0f6b272f1c
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Tue Jan 21 10:36:09 2025 +0800
Optimize retained memory size calculation for getRegion method of BinaryColumn
---
.../read/common/block/column/BinaryColumn.java | 31 +++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/BinaryColumn.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/BinaryColumn.java
index 9b8a82cc4..0100b0c65 100644
--- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/BinaryColumn.java
+++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/BinaryColumn.java
@@ -78,6 +78,34 @@ public class BinaryColumn implements Column {
retainedSizeInBytes = INSTANCE_SIZE + sizeOfBooleanArray(positionCount) + sizeOf(values);
}
+ // called by getRegion which already knows the underlying retainedSizeInBytes
+ private BinaryColumn(
+ int arrayOffset,
+ int positionCount,
+ boolean[] valueIsNull,
+ Binary[] values,
+ long retainedSizeInBytes) {
+ if (arrayOffset < 0) {
+ throw new IllegalArgumentException("arrayOffset is negative");
+ }
+ this.arrayOffset = arrayOffset;
+ if (positionCount < 0) {
+ throw new IllegalArgumentException("positionCount is negative");
+ }
+ this.positionCount = positionCount;
+
+ if (values.length - arrayOffset < positionCount) {
+ throw new IllegalArgumentException("values length is less than positionCount");
+ }
+ this.values = values;
+
+ if (valueIsNull != null && valueIsNull.length - arrayOffset < positionCount) {
+ throw new IllegalArgumentException("isNull length is less than positionCount");
+ }
+ this.valueIsNull = valueIsNull;
+ this.retainedSizeInBytes = retainedSizeInBytes;
+ }
+
@Override
public TSDataType getDataType() {
return TSDataType.TEXT;
@@ -141,7 +169,8 @@ public class BinaryColumn implements Column {
@Override
public Column getRegion(int positionOffset, int length) {
checkValidRegion(getPositionCount(), positionOffset, length);
- return new BinaryColumn(positionOffset + arrayOffset, length, valueIsNull, values);
+ return new BinaryColumn(
+ positionOffset + arrayOffset, length, valueIsNull, values, getRetainedSizeInBytes());
}
@Override