yifan-c commented on code in PR #73:
URL: 
https://github.com/apache/cassandra-analytics/pull/73#discussion_r1716138859


##########
cassandra-analytics-core/src/main/java/org/apache/cassandra/spark/bulkwriter/blobupload/StorageClient.java:
##########
@@ -216,7 +215,8 @@ private List<CompletedPart> uploadPartsOfBundle(String key, 
String uploadId,
             {
                 int loopPartNumber = partNumber;
                 ByteBuffer buffer = chunks.next();
-                AsyncRequestBody body = 
AsyncRequestBody.fromBytes(ByteBufferUtils.getArray(buffer));
+                // get a copy of the remaining ByteBuffer; for the last chunk, 
the cloned ByteBuffer is resized accordingly.
+                AsyncRequestBody body = 
AsyncRequestBody.fromRemainingByteBuffer(buffer);

Review Comment:
   `AsyncRequestBody.fromBytes(ByteBufferUtils.getArray(buffer))` copies data 2 
times.. 
   1. copy from buffer to byte array
   2. copy from byte array to another byte array in `AsyncRequestBody.fromBytes`
   
   By switching to `AsyncRequestBody.fromRemainingByteBuffer`, it copies once, 
i.e. reduce 1 data copy 



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

Reply via email to