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

Jean-Marc Spaggiari commented on HBASE-9935:
--------------------------------------------

Nice one again. We should take more attention when we call external methodes on 
the same object multiple time and see if we are not better to do it once and 
store the result.

One improvement we can do here, is to store the row lenght and invalidate it 
only if it changes? Like

{code}
@Override
public short getRowLength() {
  if (rowLength == null)
    rowLength = Bytes.toShort(this.bytes, getKeyOffset());
  return rowLength;
}
{code}

And then each time we modify this.offset or this.byte we invalidate 
rowLenght... So that will optimize everywhere even if we missed it? Looking 
very quickly at the KV code, I have not seen anywhere except in the constructor 
where this is modified. So might be a quick and small optimization again...

> Slight perf improvement: Avoid KeyValue.getRowLength() at some places
> ---------------------------------------------------------------------
>
>                 Key: HBASE-9935
>                 URL: https://issues.apache.org/jira/browse/HBASE-9935
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Lars Hofhansl
>
> Here's an example:
> {code}
> KeyValue.createLastOnRow(
>           kv.getBuffer(), kv.getRowOffset(), kv.getRowLength(),
>           kv.getBuffer(), kv.getFamilyOffset(), kv.getFamilyLength(),
>            kv.getBuffer(), kv.getQualifierOffset(), kv.getQualifierLength());
> {code}
> Looks harmless enough, but that actually recalculates the rowlength 5 times. 
> And each time it needs to decode the rowlength again from the bytes of the KV.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to