gortiz commented on code in PR #15571:
URL: https://github.com/apache/pinot/pull/15571#discussion_r2058307782
##########
pinot-common/src/main/java/org/apache/pinot/common/datablock/DataBlockUtils.java:
##########
@@ -230,6 +230,28 @@ public static ByteString toByteString(DataBlock dataBlock)
return byteString;
}
+ public static List<ByteString> toByteStrings(DataBlock dataBlock, int
maxBlockSize)
+ throws IOException {
+ List<ByteBuffer> bytes = dataBlock.serialize();
+ if (bytes.isEmpty()) {
+ return List.of(ByteString.EMPTY);
+ }
+
+ List<ByteString> byteStrings = new ArrayList<>();
+ ByteString current = UnsafeByteOperations.unsafeWrap(bytes.get(0));
+ for (int i = 1; i < bytes.size(); i++) {
+ ByteBuffer bb = bytes.get(i);
+ if (current.size() + bb.remaining() > maxBlockSize) {
+ byteStrings.add(current);
+ current = UnsafeByteOperations.unsafeWrap(bb);
+ } else {
+ current = current.concat(UnsafeByteOperations.unsafeWrap(bb));
+ }
+ }
Review Comment:
Why would it need array copies? we just need to create views on the
bytebuffer, right? The only issue is that it may be more difficult to calculate
the size of the list where we are going to store these pages
--
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]