HBASE-18389 Remove byte[] from formal parameter of sizeOf() of ClassSize, ClassSize.MemoryLayout and ClassSize.UnsafeLayout
Signed-off-by: Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
parent
d5c6e11016
commit
946289113a
|
@ -564,7 +564,7 @@ public final class CellUtil {
|
|||
public long heapSize() {
|
||||
long sum = HEAP_SIZE_OVERHEAD + CellUtil.estimatedHeapSizeOf(cell);
|
||||
if (this.tags != null) {
|
||||
sum += ClassSize.sizeOf(this.tags, this.tags.length);
|
||||
sum += ClassSize.sizeOf(this.tags);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
@ -763,7 +763,7 @@ public final class CellUtil {
|
|||
long sum = HEAP_SIZE_OVERHEAD + CellUtil.estimatedHeapSizeOf(cell);
|
||||
// this.tags is on heap byte[]
|
||||
if (this.tags != null) {
|
||||
sum += ClassSize.sizeOf(this.tags, this.tags.length);
|
||||
sum += ClassSize.sizeOf(this.tags);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
@ -889,7 +889,7 @@ public final class CellUtil {
|
|||
public long heapSize() {
|
||||
long sum = ClassSize.REFERENCE + super.heapSize();
|
||||
if (this.value != null) {
|
||||
sum += ClassSize.sizeOf(this.value, this.value.length);
|
||||
sum += ClassSize.sizeOf(this.value);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
@ -989,7 +989,7 @@ public final class CellUtil {
|
|||
public long heapSize() {
|
||||
long sum = ClassSize.REFERENCE + super.heapSize();
|
||||
if (this.value != null) {
|
||||
sum += ClassSize.sizeOf(this.value, this.value.length);
|
||||
sum += ClassSize.sizeOf(this.value);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
|
|
@ -2608,8 +2608,8 @@ public class KeyValue implements ExtendedCell {
|
|||
*/
|
||||
return ClassSize.align(sum) +
|
||||
(offset == 0
|
||||
? ClassSize.sizeOf(bytes, length) // count both length and object overhead
|
||||
: length); // only count the number of bytes
|
||||
? ClassSize.sizeOfByteArray(length) // count both length and object overhead
|
||||
: length); // only count the number of bytes
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -159,7 +159,7 @@ public class ClassSize {
|
|||
return ((num + 7) >> 3) << 3;
|
||||
}
|
||||
|
||||
long sizeOf(byte[] b, int len) {
|
||||
long sizeOfByteArray(int len) {
|
||||
return align(arrayHeaderSize() + len);
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ public class ClassSize {
|
|||
|
||||
@Override
|
||||
@SuppressWarnings("static-access")
|
||||
long sizeOf(byte[] b, int len) {
|
||||
long sizeOfByteArray(int len) {
|
||||
return align(arrayHeaderSize() + len * UnsafeAccess.theUnsafe.ARRAY_BYTE_INDEX_SCALE);
|
||||
}
|
||||
}
|
||||
|
@ -444,8 +444,34 @@ public class ClassSize {
|
|||
return model != null && model.equals("32");
|
||||
}
|
||||
|
||||
public static long sizeOf(byte[] b, int len) {
|
||||
return memoryLayout.sizeOf(b, len);
|
||||
/**
|
||||
* Calculate the memory consumption (in byte) of a byte array,
|
||||
* including the array header and the whole backing byte array.
|
||||
*
|
||||
* If the whole byte array is occupied (not shared with other objects), please use this function.
|
||||
* If not, please use {@link #sizeOfByteArray(int)} instead.
|
||||
*
|
||||
* @param b the byte array
|
||||
* @return the memory consumption (in byte) of the whole byte array
|
||||
*/
|
||||
public static long sizeOf(byte[] b) {
|
||||
return memoryLayout.sizeOfByteArray(b.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the memory consumption (in byte) of a part of a byte array,
|
||||
* including the array header and the part of the backing byte array.
|
||||
*
|
||||
* This function is used when the byte array backs multiple objects.
|
||||
* For example, in {@link org.apache.hadoop.hbase.KeyValue},
|
||||
* multiple KeyValue objects share a same backing byte array ({@link org.apache.hadoop.hbase.KeyValue#bytes}).
|
||||
* Also see {@link org.apache.hadoop.hbase.KeyValue#heapSize()}.
|
||||
*
|
||||
* @param len the length (in byte) used partially in the backing byte array
|
||||
* @return the memory consumption (in byte) of the part of the byte array
|
||||
*/
|
||||
public static long sizeOfByteArray(int len) {
|
||||
return memoryLayout.sizeOfByteArray(len);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue