jpountz commented on PR #12841:
URL: https://github.com/apache/lucene/pull/12841#issuecomment-1845316218

   > The only downside of this is that the caller code must know beforehand how 
large the slice must be.
   
   I think that there is another downside, which is that this might not allow 
you to read 4 bytes for each integer. E.g. let's assume the simple case of 4 
integers that are less than 256. The header byte is `0` in that case. So we 
know we need 4 bytes and can get a ByteBuffer of size 4. But then we'd like to 
`ByteBuffer#getInt()` at offsets 0, 1, 2 and 3 on that `ByteBuffer`, which 
can't be done for the last 3 integers since it has a size of 4?
   
   Alternatively, could we read 17 bytes all the time and do something like 
below?
   
   ```java
   try {
     ByteBuffer nextBytes = in.readByteBuffer(17);
     <decoding logic>
     in.seek(in.getPosition() - nextBytes().remaining()); // rewind unread bytes
   } catch (EOFException e) {
     // naive impl
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to