You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Xiang Li (JIRA)" <ji...@apache.org> on 2017/07/21 09:06:00 UTC
[jira] [Comment Edited] (HBASE-18389) Remove byte[] from formal
parameter of sizeOf() of ClassSize, ClassSize.MemoryLayout and
ClassSize.UnsafeLayout
[ https://issues.apache.org/jira/browse/HBASE-18389?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16089524#comment-16089524 ]
Xiang Li edited comment on HBASE-18389 at 7/21/17 9:05 AM:
-----------------------------------------------------------
Uploaded patch 000 to make some changes:
# In ClassSize.MemoryLayout and ClassSize.UnsafeLayout
## Remove byte[] b from the formal parameters of sizeOf(), and keep byte[] b
## Rename sizeOf() into sizeOfByteArray()
# In ClassSize
Replace sizeOf(byte[] b, int len) with 2 functions
## sizeOf(byte[] b). Used when the whole backing byte array is considered, such as in CellUtil.TagRewriteCell#heapSize(), CellUtil.TagRewriteByteBufferCell#heapSize(), CellUtil.ValueAndTagRewriteCell#heapSize() and CellUtil.ValueAndTagRewriteByteBufferCell#heapSize()
## sizeOfPartOfByteArray(int len). Used when the byte array backs (be shared by) multiple objects, such as in KeyValue#heapSize()
It works as:
* ClassSize#sizeOf(byte[]) and ClassSize#sizeOfPartOfByteArray(int) are the public interfaces to be called when the memory consumption of a byte array is to be calculated. Callers only need to care about it is the whole byte array to calculate or a part of it.
* The sizeOfByteArray() of ClassSize.MemoryLayout and ClassSize.UnsafeLayout are hidden behind ClassSize#sizeOf(byte[]) and ClassSize#sizeOfByteArray(int) to deal with the internal logic
was (Author: water):
Uploaded patch 000 to make some changes:
# In ClassSize.MemoryLayout and ClassSize.UnsafeLayout
## Remove byte[] b from the formal parameters of sizeOf(), and keep byte[] b
## Rename sizeOf() into sizeOfByteArray()
# In ClassSize
Replace sizeOf(byte[] b, int len) with 2 functions
## sizeOf(byte[] b). Used when the whole backing byte array is considered, such as in CellUtil.TagRewriteCell#heapSize(), CellUtil.TagRewriteByteBufferCell#heapSize(), CellUtil.ValueAndTagRewriteCell#heapSize() and CellUtil.ValueAndTagRewriteByteBufferCell#heapSize()
## sizeOfPartOfByteArray(int len). Used when the byte array backs (be shared by) multiple objects, such as in KeyValue#heapSize()
It works as:
* ClassSize#sizeOf(byte[]) and ClassSize#sizeOfByteArray(int) are the public interfaces to be called when the memory consumption of a byte array is to be calculated. Callers only need to care about it is the whole byte array to calculate or a part of it.
* The sizeOfByteArray() of ClassSize.MemoryLayout and ClassSize.UnsafeLayout are hidden behind ClassSize#sizeOf(byte[]) and ClassSize#sizeOfByteArray(int) to deal with the internal logic
> Remove byte[] from formal parameter of sizeOf() of ClassSize, ClassSize.MemoryLayout and ClassSize.UnsafeLayout
> ---------------------------------------------------------------------------------------------------------------
>
> Key: HBASE-18389
> URL: https://issues.apache.org/jira/browse/HBASE-18389
> Project: HBase
> Issue Type: Bug
> Components: util
> Reporter: Xiang Li
> Assignee: Xiang Li
> Priority: Minor
> Attachments: HBASE-18389.master.000.patch, HBASE-18389.master.001.patch, HBASE-18389.master.002.patch
>
>
> In ClassSize class and its internal static class, sizeOf() function has 2 formal parameters: byte[] b and int len. But the function's internal logic does not use or refer to byte[] b. Could be removed.
> {code:title=hbase-common/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java|borderStyle=solid}
> // Class of ClassSize
> public static long sizeOf(byte[] b, int len) {
> return memoryLayout.sizeOf(b, len);
> }
> // Class of ClassSize.MemoryLayout
> long sizeOf(byte[] b, int len) {
> return align(arrayHeaderSize() + len);
> }
> // Class of ClassSize.UnsafeLayout
> long sizeOf(byte[] b, int len) {
> return align(arrayHeaderSize() + len * UnsafeAccess.theUnsafe.ARRAY_BYTE_INDEX_SCALE);
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)