steveniemitz commented on PR #22144:
URL: https://github.com/apache/beam/pull/22144#issuecomment-1172938645

   > It seems as though ByteString.readFrom honors the size we pass in so it 
only creates one chunk, but then it copies the bytes again (for immutability 
purposes)
   
   Yeah, there's a couple problems with it:
   - we end up allocating a 10 element object[] in the `results` ArrayList to 
hold a single element.
   - since readChunk is called twice (one to read all the data, another to 
return null), we allocate an extra buffer there which gets thrown away once it 
realizes that there's nothing left to read (read returns -1).
   - as you mentioned, a copy from the temp buffer into the resulting 
ByteString.


-- 
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]

Reply via email to