You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by jackwang <wa...@gmail.com> on 2016/10/27 17:02:45 UTC

Is Hbase cell clone operation necessary and expensive

When I read Hbase source code, I was confused that why Hbase use clone() to
read columns. Does the clone operator very expensive since the cell already
read out to client from server,but the clone will create a new byte array.
The source code as following:

public static byte[] cloneValue(Cell cell){
    byte[] output = new byte[cell.getValueLength()];
    copyValueTo(cell, output, 0);
    return output;
}



--
View this message in context: http://apache-hbase.679495.n3.nabble.com/Is-Hbase-cell-clone-operation-necessary-and-expensive-tp4083807.html
Sent from the HBase User mailing list archive at Nabble.com.

Re: Is Hbase cell clone operation necessary and expensive

Posted by Stack <st...@duboce.net>.
On Fri, Oct 28, 2016 at 7:33 PM, jackwang <wa...@gmail.com> wrote:

> Thank you so much, do you suggest me to use getValueAsByteBuffer(byte[],
> byte[])}. For my side I really think we don't have to use clone, because I
> will not update anything in the original cell.
>
>
> Then yes, you are good to use getValueAsByteBuffer.
Good luck,
S




>
> --
> View this message in context: http://apache-hbase.679495.n3.
> nabble.com/Is-Hbase-cell-clone-operation-necessary-and-
> expensive-tp4083807p4083874.html
> Sent from the HBase User mailing list archive at Nabble.com.
>

Re: Is Hbase cell clone operation necessary and expensive

Posted by jackwang <wa...@gmail.com>.
Thank you so much, do you suggest me to use getValueAsByteBuffer(byte[],
byte[])}. For my side I really think we don't have to use clone, because I
will not update anything in the original cell.



--
View this message in context: http://apache-hbase.679495.n3.nabble.com/Is-Hbase-cell-clone-operation-necessary-and-expensive-tp4083807p4083874.html
Sent from the HBase User mailing list archive at Nabble.com.

Re: Is Hbase cell clone operation necessary and expensive

Posted by Stack <st...@duboce.net>.
On Thu, Oct 27, 2016 at 10:02 AM, jackwang <wa...@gmail.com> wrote:

> When I read Hbase source code, I was confused that why Hbase use clone() to
> read columns. Does the clone operator very expensive since the cell already
> read out to client from server,but the clone will create a new byte array.
> The source code as following:
>
> public static byte[] cloneValue(Cell cell){
>     byte[] output = new byte[cell.getValueLength()];
>     copyValueTo(cell, output, 0);
>     return output;
> }
>
>
>
We clone when we are giving data to the application and there is the
possibility that modification could damage the view we present.

In Result, when application asks for values, we'll clone. You can avoid the
clone, as it says in the API, by:

   * Note: this call clones the value content of the hosting Cell. See

   * {@link #getValueAsByteBuffer(byte[], byte[])}, etc., or {@link
#listCells()} if you would

   * avoid the cloning."

Thanks,

St.Ack


>
> --
> View this message in context: http://apache-hbase.679495.n3.
> nabble.com/Is-Hbase-cell-clone-operation-necessary-and-
> expensive-tp4083807.html
> Sent from the HBase User mailing list archive at Nabble.com.
>