cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stu Hood (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CASSANDRA-1661) Use of ByteBuffer limit() must account for arrayOffset()
Date Mon, 25 Oct 2010 16:25:19 GMT

    [ https://issues.apache.org/jira/browse/CASSANDRA-1661?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12924612#action_12924612
] 

Stu Hood commented on CASSANDRA-1661:
-------------------------------------

* A few of the loops involving direct array access (in particular the one in RandomPartitioner)
could be simplified with judicious use of mark() and get()
* Adding the follow function and using it in the tests would clarify things a lot: CFSTest
looks like it exploded.
{code:java}public static ByteBuffer bytes(String s) { return ByteBuffer.wrap(s.getBytes(UTF_8));
}{code}
* Converting BytesToken to ByteBuffer storage would clean up a ton of special casing (should
probably be tackled in a separate issue though)
* ByteBufferTest is literally a test of ByteBuffers: I don't think it should be in C*

Thanks!

> Use of ByteBuffer limit() must account for arrayOffset() 
> ---------------------------------------------------------
>
>                 Key: CASSANDRA-1661
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-1661
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 0.7.0
>            Reporter: T Jake Luciani
>            Assignee: T Jake Luciani
>             Fix For: 0.7.0
>
>         Attachments: 1661_v1.txt
>
>
> There are a few places in the code where it loops across a byte buffers backing array
wrong:
>         for (int i=bytes.position()+bytes.arrayOffset(); i<bytes.limit(); i++)
> This is incorrect as the limit() does not account for arrayOffset()
>               for (int i=bytes.position()+bytes.arrayOffset(); i<bytes.limit()+bytes.arrayOffset();
i++)
> is the correct code.
> There is also a few places where the unit tests would fail if we used non wrapped byte
arrays.

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


Mime
View raw message