You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Benedict (JIRA)" <ji...@apache.org> on 2015/06/16 02:33:00 UTC

[jira] [Comment Edited] (CASSANDRA-9499) Introduce writeVInt method to DataOutputStreamPlus

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

Benedict edited comment on CASSANDRA-9499 at 6/16/15 12:32 AM:
---------------------------------------------------------------

Thanks.

I know Cap'n Proto and our existing code uses a loop, but why not just use {{8 - Integer.numberOfLeadingZeros\(v\)/8}} ?

The cyclic dependency between {{EncodedDIS}} and AbstractDIS is a bit confusing to me. I'd rather we simply marked {{EncodedDIS @Deprecated}}, and moved all of the implementation details somewhere that's acyclic.

The read method we can make quite a bit more efficient, with a special version of {{prepareReadPrimitive}}: we want the result to be that {{length}} bytes are in the buffer for consumptions,but that we are also 8 bytes or more before the end of the buffer. This way we can just call {{buffer.getLong(buffer.position())}}, then advance its position by {{length}} and truncate the long with {{ & (-1L >>> (64 - (length * 8)) }} (where {{length}} here excludes the initial size byte)

It occurs to me there's nothing stopping us using this approach for writing as well, simply calling putLong(), with an optional writeByte() to fill in the most-significant byte if it was non-empty.


was (Author: benedict):
Thanks.

I know Cap'n Proto and our existing code uses a loop, but why not just use {{8 - Integer.numberOfLeadingZeros\(v\)/8}} ?

The cyclic dependency between {{EncodedDIS}} and AbstractDIS is a bit confusing to me. I'd rather we simply marked {{EncodedDIS @Deprecated}}, and moved all of the implementation details somewhere that's acyclic.

The read method we can make quite a bit more efficient, with a special version of {{prepareReadPrimitive}}: we want the result to be that {{length}} bytes are in the buffer for consumptions,but that we are also 8 bytes or more before the end of the buffer. This way we can just call {{buffer.getLong(buffer.position())}}, then advance its position by {{length}} and truncate the long with {{ & (-1L >>> (64 - (length * 8)) }} (where {{length}} here excludes the initial size byte)

> Introduce writeVInt method to DataOutputStreamPlus
> --------------------------------------------------
>
>                 Key: CASSANDRA-9499
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-9499
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: Core
>            Reporter: Benedict
>            Assignee: Ariel Weisberg
>            Priority: Minor
>             Fix For: 3.0 beta 1
>
>
> CASSANDRA-8099 really could do with a writeVInt method, for both fixing CASSANDRA-9498 but also efficiently encoding timestamp/deletion deltas. It should be possible to make an especially efficient implementation against BufferedDataOutputStreamPlus.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)