[ 
https://issues.apache.org/jira/browse/HBASE-16888?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15591908#comment-15591908
 ] 

ChiaPing Tsai commented on HBASE-16888:
---------------------------------------

Thanks for your feedback.

The call hierarchy is shown below. (if cell.getTagsLength() != 0)
# KeyValueUtil.copyCellTo(this, buf, 0, size);
# TagRewriteCell#write(byte[] buf, int offset)

{noformat}
    public void write(byte[] buf, int offset) {
      offset = KeyValueUtil.appendToByteArray(this.cell, buf, offset, false);
      int tagsLen = this.tags.length;
      assert tagsLen > 0;
      offset = Bytes.putAsShort(buf, offset, tagsLen);
      System.arraycopy(this.tags, 0, buf, offset, tagsLen);
    }
{noformat}
It copies the this.tags instead of this.cell's tags.
But the ShareableMemory#cloneToCell may copy the this.cell's tags because it 
doesn't accept the argument like "withTags"

bq. The size is not used in restricting the copy
It seems to me that the size is the bytes count of this.cell(w/o tags) and 
this.tags, which are together serialized in KeyValue format. The correct size 
is used for preventing unused bytes.

Thanks

> Avoid unnecessary tags copy in Append
> -------------------------------------
>
>                 Key: HBASE-16888
>                 URL: https://issues.apache.org/jira/browse/HBASE-16888
>             Project: HBase
>          Issue Type: Improvement
>    Affects Versions: 2.0.0
>            Reporter: ChiaPing Tsai
>            Assignee: ChiaPing Tsai
>            Priority: Minor
>             Fix For: 2.0.0
>
>         Attachments: HBASE-16888.v0.patch
>
>
> a) If the delta has tags and the mutation doesn’t apply the TTL, we shouldn’t 
> create the TagRewriteCell.
> {noformat}
>     List<Tag> tags = TagUtil.carryForwardTags(delta);
>     long ts = now;
>     Cell newCell = null;
>     byte [] row = mutation.getRow();
>     if (currentValue != null) {
>      ...
>     } else {
>       // Append's KeyValue.Type==Put and ts==HConstants.LATEST_TIMESTAMP
>       CellUtil.updateLatestStamp(delta, now);
>       newCell = delta;
>       tags = TagUtil.carryForwardTTLTag(tags, mutation.getTTL());
>       if (tags != null) {
>         newCell = CellUtil.createCell(delta, tags);
>       }
>     }
> {noformat}
> b) If the cell has tags, the ShareableMemoryTagRewriteCell will make 
> duplicate copy of tags. 
> {noformat}
>       Cell clonedBaseCell = ((ShareableMemory) this.cell).cloneToCell();
>       return new TagRewriteCell(clonedBaseCell, this.tags);
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to