[
https://issues.apache.org/jira/browse/HBASE-7137?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Hiroshi Ikeda updated HBASE-7137:
---------------------------------
Attachment: HBASE-7137-V2.patch
bq. In toBytes, we do dup.postion(0) but we don't do this when we do getBytes.
Should we? Should getBytes make use of toBytes?
At first I thought that the methods Bytes.toBytes(ByteBuffer) and
toStringBinary(ByteBuffer) would be used for error logs, because it is required
to reset the position to 0 and write down the whole contents of the byte buffer
if the exception is thrown from the middle of reading data from the byte buffer.
But it seems the methods are not used for the purpose. I am not sure why the
similar methods, Bytes.toByte(ByteBuffer) and getBytes(ByteBuffer), are
prepared. It might be possible to replace calling toByte(ByteBuffer) with
calling getByte(ByteBuffer) inside HBase.
Anyway, for the class Bytes, it is annotated as stable, and we can only extend
the specification with keeping the compatibility.
Added a revised patch; In the previous patch the implementations of
Bytes.toBytes(ByteBuffer) and getByte(ByteBuffer) are quite similar, and in the
new patch I extracted the shared logic between the methods into a new private
method.
> Improve Bytes to accept byte buffers which don't allow us to directly access
> thier backed arrays
> ------------------------------------------------------------------------------------------------
>
> Key: HBASE-7137
> URL: https://issues.apache.org/jira/browse/HBASE-7137
> Project: HBase
> Issue Type: Improvement
> Reporter: Hiroshi Ikeda
> Priority: Minor
> Attachments: HBASE-7137.patch, HBASE-7137-V2.patch
>
>
> Inside HBase, it seems that there is the implicit assumption that byte
> buffers have backed arrays and are not read-only, and we can freely call
> ByteBuffer.array() and arrayOffset() without runtime exceptions.
> But some classes, including Bytes, are supposed to be used by users from
> outside of HBase, and we should think the possibility that methods receive
> byte buffers which don't hold the assumption.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira