Jackie-Jiang commented on code in PR #20069:
URL: https://github.com/apache/pinot/pull/20069#discussion_r4406851294
##########
pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/memory/PinotDataBuffer.java:
##########
@@ -649,6 +650,16 @@ public ByteBuffer toDirectByteBuffer(long offset, int
size) {
return toDirectByteBuffer(offset, size, order());
}
+ /// Reads a range synchronously through a borrowed direct buffer with this
receiver's byte order.
Review Comment:
Minor documentation nit: this promises a direct buffer, but
`PinotByteBuffer.wrap(byte[])` inherits this implementation and supplies a
heap-backed slice (`EmptyIndexBuffer` also supplies a heap buffer). Please
describe this as a borrowed `ByteBuffer`, with directness depending on the
receiver, so callers don't assume they can always pass it to an API requiring
direct buffers.
##########
pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/memory/PinotDataBuffer.java:
##########
@@ -649,6 +650,16 @@ public ByteBuffer toDirectByteBuffer(long offset, int
size) {
return toDirectByteBuffer(offset, size, order());
}
+ /// Reads a range synchronously through a borrowed direct buffer with this
receiver's byte order.
+ /// The callback receives a buffer positioned at zero with its limit set to
`size`. It may change the position
+ /// and limit, but must not modify the contents, release the buffer, or
retain or return the buffer or any alias.
+ /// The callback must not recursively access or release this receiver or its
views. The borrowed buffer is only
+ /// valid during the callback; the result must be independent of it.
+ public <T> T readWithByteBuffer(long offset, int size,
IOFunction<ByteBuffer, T> reader)
Review Comment:
Optional naming suggestion: consider `withByteBuffer(...)` to emphasize that
access is scoped to the callback. That lifetime distinction from
`toDirectByteBuffer(...)` is the main value of the new API. This is
non-blocking.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]