albertobastos commented on code in PR #15571:
URL: https://github.com/apache/pinot/pull/15571#discussion_r2060203202


##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/mailbox/channel/MailboxContentObserver.java:
##########
@@ -58,10 +61,18 @@ public void onNext(MailboxContent mailboxContent) {
     if (_mailbox == null) {
       _mailbox = _mailboxService.getReceivingMailbox(mailboxId);
     }
+    if (_mailboxBuffers == null) {
+      _mailboxBuffers = new ArrayList<>();
+    }

Review Comment:
   Nice one. I always assumed it just used a default capacity, but that makes a 
lot more sense.



##########
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:
   That took a while and some struggling using so many bytebuffer wrappers, but 
I believe we finally got it.
   
   Changed the implementation so the split strategy is more optimal: it fills 
as many _maxByteStringSize_ `ByteString`s instances as needed, splitting the 
raw data among them. No buffer copies involved.



-- 
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: commits-unsubscr...@pinot.apache.org

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


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

Reply via email to