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] [Created] (HBASE-15233) Bytes.toBytes() methods should allow arrays to be re-used
Date Mon, 08 Feb 2016 20:12:39 GMT
Jean-Marc Spaggiari created HBASE-15233:
-------------------------------------------

             Summary: 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
            Priority: Minor


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