Hello!
In our application we are heavily using Netty (v4) ByteBuf objects for
caching binary data. We found it to be very useful for data parsing, and we
are trying to keep number of created ByteBufs to be limited.
Sometime during data parsing we are facing a task when portion of readable
data needs to be moved to the beginning of ByteBuf.
At the moment we are using temporary ByteBuf, here is algo we use
*//prepare buffer per connection*
mainBuf = createBuffer;
tempBuf = createBuffer;
processData(ByteBuf newData) {
newData.readBytes(newData, newData.readableBytes());
* //... perform operations over the mainBuf*
mainBuf.readBytes(tempBuf, mainBuf.readableBytes());* // copy data into
tempBuf into the beginning*
tmp = mainBuf;
mainBuf = tempBuf;
tempBuf = tmp;
* //'discard all data'*
tempBuf.resetReaderIndex();
tempBuf.resetWriterIndex();
}
Since our applications keeps huge number of buffers, we are looking for the
way to remove requirement to have tempBuf ByteBuf.
What is the most optimal way to copy data from the middle to the beginning,
and update readed/writer index accordingly?
Thank you!
--
You received this message because you are subscribed to the Google Groups
"Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/netty/7ac75f53-d410-4096-a07f-4c964d56cd60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.