hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jean-Marc Spaggiari (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HBASE-15233) Bytes.toBytes() methods should allow arrays to be re-used
Date Thu, 12 May 2016 12:58:12 GMT

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

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

When this will be implemented we will have to open new JIRAs for other optimizations.

Like still in CellCodec. If we change:
{code}
    private void write(final byte [] bytes, final int offset, final int length)
    throws IOException {
      // TODO add BB backed os check and do for write. Pass Cell
      this.out.write(Bytes.toBytes(length));
      this.out.write(bytes, offset, length);
    }
{code}

by 
{code}
    private void write(final byte [] bytes, final int offset, final byte[] length)
    throws IOException {
      // TODO add BB backed os check and do for write. Pass Cell
      this.out.write(length);
      this.out.write(bytes, offset, Bytes.toInt(length));
    }
{code}

Then when we call write, we can again re-use the byte array and save again on objects creation...
I will open another JIRA for CellCode optimizations...


> Bytes.toBytes() methods should allow arrays to be re-used 
> ----------------------------------------------------------
>
>                 Key: HBASE-15233
>                 URL: https://issues.apache.org/jira/browse/HBASE-15233
>             Project: HBase
>          Issue Type: Improvement
>          Components: API
>    Affects Versions: 1.1.3
>            Reporter: Jean-Marc Spaggiari
>            Assignee: Michael Ernest
>            Priority: Minor
>              Labels: beginner
>
> Today we have this:
> {code}
>   public static byte[] toBytes(long val) {
>     byte [] b = new byte[8];
>     for (int i = 7; i > 0; i--) {
>       b[i] = (byte) val;
>       val >>>= 8;
>     }
>     b[0] = (byte) val;
>     return b;
>   }
> {code}
> might be nice to also have this:
> {code}
>   public static byte[] toBytes(long val, byte[] reuse) {
>     for (int i = 7; i > 0; i--) {
>       reuse[i] = (byte) val;
>       val >>>= 8;
>     }
>     reuse[0] = (byte) val;
>     return reuse;
>   }
> {code}
> Same for all the other Bytes.toBytes() methods.



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

Mime
View raw message