[
https://issues.apache.org/jira/browse/HBASE-15233?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15138878#comment-15138878
]
Jean-Marc Spaggiari commented on HBASE-15233:
---------------------------------------------
When doing MR job to to create HFiles for bulkload. If you key is a long, like,
timestamp, or what ever. Instead of creating a byte[] at each mapper iteration
you might want to re-use it... The same is true for any type. Long, Booleans,
etc. And not just for the key, but also if it's in the values.
You can also for sure easily just re-implement Bytes.toBytes() in your own
utility class or directly in your mapper, but might be consistent to see those
methods added there since they are already very similar to what we have.
Hope it makes sense for you.
> 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: Rachel Asher Silver
> 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)