[ 
https://issues.apache.org/jira/browse/CASSANDRA-1998?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sylvain Lebresne updated CASSANDRA-1998:
----------------------------------------

    Attachment: 0002-Move-EMPTY_BYTE_BUFFER-to-ByteBufferUtil.patch
                0001-Make-BB-offset-relative-to-position.patch

The attached patch does a little bit more that what's in the ticket
description in that it tries to "clean" a bit more our use of ByteBuffers.
More precisely, not only does it changes the ByteBufferUtil functions to use
offset relative the position, but it also moves the few last methods of
FBUtilities that handle ByteBuffers to ByteBufferUtil.

A second patch moves FBUtilies.EMPTY_BYTE_BUFFER to
ByteBufferUtil.EMPTY_BYTE_BUFFER, but this is called so damn often that I
figured maybe we won't want to go there.

Anyway, I suppose those refactorings are debatable, so I figured I mention
that the first patch also contains good old bug fixes. Two remaining calls to
getLong() with an arrayOffset() as parameter. And more importantly bad usage
of ByteBufferUtil.string(): it takes a start offset and a length, but is used
as if it was taking a start and and end offset.

If the remaining of the patch is note accepted, I'll extract those two fixes
(but I'd rather not have to :)).

And the patch is against trunk (I'll make one against 0.7 if there is
interest).


> Make offsets in ByteBufferUtil.* methods relatif to the ByteBuffer position()
> -----------------------------------------------------------------------------
>
>                 Key: CASSANDRA-1998
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-1998
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 0.8
>            Reporter: Sylvain Lebresne
>            Assignee: Sylvain Lebresne
>            Priority: Minor
>             Fix For: 0.8
>
>         Attachments: 0001-Make-BB-offset-relative-to-position.patch, 
> 0002-Move-EMPTY_BYTE_BUFFER-to-ByteBufferUtil.patch
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> A few methods in ByteBufferUtil take as parameter an offset inside a
> ByteBuffer. When we use them, we always want this offset to be relative to
> ByteBuffer.position(), but it is not, it is relative to the ByteBuffer 0
> position. I argue this is not inline with the way we use ByteBuffers and as a
> consequence, is ugly and error-prone.
> This ticket proposes to make the offset of the ByteBufferUtil.* methods
> relatif to the ByteBuffer position.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to