Hello, Norman

My bad, later when reading javadoc realized there is discardReadBytes() method 
which does all i need.

On Thursday, June 23, 2016 at 12:51:04 PM UTC+3, Norman Maurer wrote:
>
> I think I may not correctly understand what you try to do.
>
> So you are saying you want to basically move some bytes (which are 
> somewhere in the buffer) to the beginning of the same buffer ?
>
> If so why you can’t just slice the part out ?
>
> On 22 Jun 2016, at 21:36, [email protected] <javascript:> wrote:
>
> 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] <javascript:>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/netty/7ac75f53-d410-4096-a07f-4c964d56cd60%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/netty/7ac75f53-d410-4096-a07f-4c964d56cd60%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
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/4181be9b-36da-43dd-8002-8988893c6165%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to