cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Lebresne <>
Subject Re: CQL3 Frame Length
Date Tue, 08 Jan 2013 16:08:41 GMT
Mostly this is because having the frame length is convenient to have in

Without pretending that there is only one way to write a server, it is
to separate the phase "read a frame from the network" from the phase "decode
the frame" which is often simpler if you can read the frame upfront. Also,
you don't have the frame size, it means you need to decode the whole frame
before being able to decode the next one, and so you can't parallelize the

It is true however that it means for the write side that you need to either
able to either pre-compute the frame body size or to serialize it in memory
first. That's a trade of for making it easier on the read side. But if you
my opinion, on the write side too it's probably worth parallelizing the
encoding (which require you encode it in memory first) since it's an
asynchronous protocol and so there will likely be multiple writer


On Tue, Jan 8, 2013 at 12:48 PM, Ben Hood <> wrote:

> Hi,
> I've read the CQL wire specification and naively, I can't see how the
> frame length length header is used.
> To me, it looks like on the read side, you know which type of structures
> to expect based on the opcode and each structure is TLV encoded.
> On the write side, you need to encode TLV structures as well, but you
> don't know the overall frame length until you've encoded it. So it would
> seem that you either need to pre-calculate the cumulative TLV size before
> you serialize the frame body, or you serialize the frame body to a buffer
> which you can then get the size of and then write to the socket, after
> having first written the count out.
> Is there potentially an implicit assumption that the reader will want to
> pre-buffer the entire frame before decoding it?
> Cheers,
> Ben

View raw message