Skip to content

Commit

Permalink
Make Binary implement Accountable
Browse files Browse the repository at this point in the history
  • Loading branch information
JackieTien97 authored Oct 22, 2024
1 parent a9f5461 commit 049a108
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion java/common/src/main/java/org/apache/tsfile/utils/Binary.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Binary>, Serializable {
public class Binary implements Comparable<Binary>, 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]);

Expand Down Expand Up @@ -116,4 +120,9 @@ public byte[] getValues() {
public void setValues(byte[] values) {
this.values = values;
}

@Override
public long ramBytesUsed() {
return INSTANCE_SIZE + sizeOf(values);
}
}

0 comments on commit 049a108

Please sign in to comment.