mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raphaël Barazzutti <raphael.barazzu...@gmail.com>
Subject Re: Codecs and CumulativeByteBuffer
Date Sun, 16 Jun 2013 19:31:54 GMT
Hi Julien,

Thanks for your comments!

You're right there are not that much differences between that two classes.

In some situations I find IoBuffer very interesting, but in the case
of a decoder there are some concepts taken from ByteBuffer that in my
opinion don't fit very well.

Lets describe briefly a case: In a decoder, the IoBuffer could be used
as a connection's buffer, then a given instance would be the context
of the connection. That buffer would be somehow used as a queue and
the position p0 would be the first byte of the communication. After
having enough bytes to process a message, the position would be moved
to position p1. Then we can expect that the buffer release the byte
buffer(s) containing the bytes in the range between p0 and p1. Then it
becomes a bit complicated to define the behaviour of position(int)
when a call to position(p0) is done.
Another thing which is a bit confusing is also that I imagine that the
position should be consistent over time in an IoBuffer (i.e. p1-p0-1
is equal to the number of bytes between p0 and p1), the drawback of
this consistency is that the communication cannot exceed
Integer.MAX_VALUE bytes when enforcing it.

That's why I didn't use at all the concept of positions/limits/etc in

Otherwise, I think I'll add support for
(get|put)(Short|Int|Long|Float|Double) in the CumulativeByteBuffer

CumulativeByteBuffer has to be moved, you're right,

Thanks again,


On Sat, Jun 15, 2013 at 10:26 PM, Julien Vermillard
<jvermillard@gmail.com> wrote:
> Hi,
> Thanks for the contribution ! keep up the good work.
> The CumulativeDecoder is a nice addition for the ones who will miss
> the old one and more in phase with the new codec API.
> On the CumulativeByteBuffer, it's not that far of IoBuffer I don't
> think we should have two class and they should merge.
> If IoBuffer could discard byte, and provide byte iterator it would be
> fine for you ?
> BTW CumulativeDecoder should be in it's own package.
> Julien
> --
> Julien Vermillard :::: http://people.apache.org/~jvermillard/
> On Sat, Jun 15, 2013 at 11:42 AM, Raphaël Barazzutti
> <raphael.barazzutti@gmail.com> wrote:
>> Hi all,
>> According to the helpful comment of Ashish (thanks!), I had to add a
>> cumulative mechanism in codec in order to have correct unserialization
>> in the Thrift module as well as in the Protobuf module.
>> Look here : https://github.com/rbarazzutti/mina.git on branch
>> serialization-fixes-1
>> For this I implemented a class named CumulativeByteBuffer to handle
>> properly these accumulating needs in the decoding phase.
>> Nevertheless another class, IoBuffer, is providing mechanisms close to
>> the one of CumulativeByteBuffer. IoBuffer has an API more similar to
>> the one of NIO's ByteBuffer, while CumulativeByteBuffer only provides
>> a subset of that API. IMHO, CumulativeByteBuffer is simpler and gives
>> some additional tools which are convenient for decoders.
>> Ready for comments,
>> Kind regards,
>> Raphaël

View raw message