ierandra commented on code in PR #2604:
URL: https://github.com/apache/jackrabbit-oak/pull/2604#discussion_r2490286210


##########
oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureArchiveManager.java:
##########
@@ -336,6 +331,73 @@ private void copyBlob(BlobItem blob, String newParent) 
throws IOException {
 
     }
 
+    private void batchCopyBlobs(List<BlobItem> from, String to) {
+        String newParent = getDirectory(to);
+
+        log.info("Start tp copy {} blobs to {}", from.size(), newParent);
+
+        int batches = from.size() / COPY_BATCH;
+        int start = 0;
+        int end = COPY_BATCH;
+
+        for (int i = 0; i < batches; i++) {
+            log.info("Start batch {}/{}: {} to {}", i + 1, batches, start, 
end);
+            List<BlobItem> blobItemsBatch = from.subList(start, end);
+            copyBlobs(blobItemsBatch, newParent);
+            start = end;
+            end += COPY_BATCH;
+        }
+
+        log.info("Copy {} to {}", start, from.size());
+        copyBlobs(from.subList(start, from.size()), newParent);

Review Comment:
   >This call is not necessary when blob count is an exact multiple of 
COPY_BATCH (e.g., 2000). Code makes an unnecessary call with an empty list.
   
   for this I can add and if like 
   ```
   if (start < from.size()) {
     log.info("Copy {} to {}", start, from.size());
     copyBlobs(from.subList(start, from.size()), newParent);
   }
   ```
   this way will not print the log and will not do the unnecessary call with an 
empty list.
   
   > For example, if the list is 2500 blobs, we will see in the log "Start 
batch 2/2 ..." (from the for loop), but the method will be invoked once more,
   
   yes, this is how I wanted to be. we have 2 batches of 1000 and then copy the 
remaining (in this case the 500).
   I was thinking to set the log like 
   ```log.info("Copy remaining  {} to {}", start, from.size());```
   but this is not ok because we can have the situation where we have less then 
1000 blobs and the batch `for` loop will not be executed.
   



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