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] 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] > <mailto:[email protected]>. > 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 > <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/5B5F24C4-A3F5-4CEE-A5AA-D639220B3D3C%40googlemail.com. For more options, visit https://groups.google.com/d/optout.
