From 049a108227a43d28dec3e0e0d8797dd4316e0505 Mon Sep 17 00:00:00 2001 From: Jackie Tien Date: Tue, 22 Oct 2024 11:55:35 +0800 Subject: [PATCH] Make Binary implement Accountable --- .../src/main/java/org/apache/tsfile/utils/Binary.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/java/common/src/main/java/org/apache/tsfile/utils/Binary.java b/java/common/src/main/java/org/apache/tsfile/utils/Binary.java index a4a696721..f65d19c34 100644 --- a/java/common/src/main/java/org/apache/tsfile/utils/Binary.java +++ b/java/common/src/main/java/org/apache/tsfile/utils/Binary.java @@ -23,12 +23,16 @@ import java.nio.charset.StandardCharsets; import java.util.Arrays; +import static org.apache.tsfile.utils.RamUsageEstimator.shallowSizeOfInstance; +import static org.apache.tsfile.utils.RamUsageEstimator.sizeOf; + /** * Override compareTo() and equals() function to Binary class. This class is used to accept Java * String type */ -public class Binary implements Comparable, Serializable { +public class Binary implements Comparable, Serializable, Accountable { + private static final long INSTANCE_SIZE = shallowSizeOfInstance(Binary.class); private static final long serialVersionUID = 6394197743397020735L; public static final Binary EMPTY_VALUE = new Binary(new byte[0]); @@ -116,4 +120,9 @@ public byte[] getValues() { public void setValues(byte[] values) { this.values = values; } + + @Override + public long ramBytesUsed() { + return INSTANCE_SIZE + sizeOf(values); + } }