TSFenwick commented on code in PR #14131:
URL: https://github.com/apache/druid/pull/14131#discussion_r1172745088


##########
extensions-core/s3-extensions/src/main/java/org/apache/druid/storage/s3/S3DataSegmentKiller.java:
##########
@@ -64,6 +69,52 @@ public S3DataSegmentKiller(
     this.inputDataConfig = inputDataConfig;
   }
 
+  @Override
+  public void killBatched(List<DataSegment> segments) throws 
SegmentLoadingException
+  {
+    int size = segments.size();
+    if (size == 0) {
+      return;
+    }
+    if (segments.size() == 1) {
+      kill(segments.get(0));
+      return;
+    }
+    try {
+      // we can assume that all segments are in the same bucket.
+      String s3Bucket = MapUtils.getString(segments.get(0).getLoadSpec(), 
"bucket");
+      final ServerSideEncryptingAmazonS3 s3Client = 
this.s3ClientSupplier.get();
+
+      // 1000 objects is the max amount of objects that can be deleted in s3 
at a time.
+      List<List<DataSegment>> segmentsChunks = Lists.partition(segments, 1000);
+      for (List<DataSegment> segmentsChunk : segmentsChunks) {
+        DeleteObjectsRequest deleteObjectsRequest = new 
DeleteObjectsRequest(s3Bucket);

Review Comment:
   does it make sense to check if object exists before calling delete on them? 
DeleteObjects wont complain if you call delete on an object that doesn't exist 
and will happily say it everything succeeded.



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