TSFenwick commented on code in PR #14131:
URL: https://github.com/apache/druid/pull/14131#discussion_r1179296416
##########
extensions-core/s3-extensions/src/main/java/org/apache/druid/storage/s3/S3DataSegmentKiller.java:
##########
@@ -64,6 +70,52 @@ public S3DataSegmentKiller(
this.inputDataConfig = inputDataConfig;
}
+ @Override
+ public void kill(List<DataSegment> segments) throws SegmentLoadingException
+ {
+ int size = segments.size();
+ if (size == 0) {
+ return;
+ }
+ if (segments.size() == 1) {
+ kill(segments.get(0));
+ return;
+ }
+
+ // 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) {
+ try {
+ DeleteObjectsRequest deleteObjectsRequest = new
DeleteObjectsRequest(s3Bucket);
+ String[] keys = segmentsChunk.stream()
+ .map(segment -> MapUtils.getString(segment.getLoadSpec(),
"key"))
+ .toArray(String[]::new);
+ deleteObjectsRequest = deleteObjectsRequest.withKeys(keys);
Review Comment:
ok will get rid of the return result on delete objects as it's not needed
with this flag
--
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]