reddycharan opened a new issue #1238: Question regarding update of 
reader/writer indexes of ByteBuf in our client API
URL: https://github.com/apache/bookkeeper/issues/1238
 
 
   **QUESTION**
   
   Regarding the updates to readerIndex/writerIndex of ByteBuf by API method, 
AFAIU if the API method is doing read operation from the ByteBuf then after 
calling API method with ByteBuf argument, I wouldn?t expect the readerIndex of 
the ByteBuf to be at 0.
   
   I mean
   
   ```
   myApplicationMethod() {
   
       ByteBuf byteBuf = createNewInstanceOfByteBuf();
       // add data to byteBuf
       APIClass.APIReadMethod(bytebuf);
       // here I would expect the readerIndex and writerIndex of byteBuf to be 
the same,
      // since APIReadMethod has consumed/read all of the data in the byteBuf
   }
   ```
   But in our case, WriteAdvHandle.write(long entryId, ByteBuf data) doesn?t 
advances readerIndex of data ByteBuf and this might be because of the following 
clone 
https://github.com/apache/bookkeeper/blob/19846b23de3be13e28082d4ba73e21bb8fa39ad2/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieProtocol.java#L271
 
   
   I would expect it to behave in the same way as other core java APIs deal 
with ByteBuffer - for eg: 
https://docs.oracle.com/javase/7/docs/api/java/nio/channels/FileChannel.html#read(java.nio.ByteBuffer)
  
https://netty.io/4.0/api/io/netty/buffer/ByteBuf.html#readBytes-io.netty.buffer.ByteBuf-
 here position of ByteBuffer and readerIndex of ByteBuf is advanced.
   
   **Que:** Are we following general practices of Buffers with our API?  Have 
we mentioned the expected behavior in detail in our API docs?
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to