georgew5656 commented on code in PR #15770:
URL: https://github.com/apache/druid/pull/15770#discussion_r1470246419
##########
extensions-core/azure-extensions/src/main/java/org/apache/druid/storage/azure/AzureDataSegmentKiller.java:
##########
@@ -63,6 +69,79 @@ public AzureDataSegmentKiller(
this.azureCloudBlobIterableFactory = azureCloudBlobIterableFactory;
}
+ @Override
+ public void kill(List<DataSegment> segments) throws SegmentLoadingException
+ {
+ if (segments.isEmpty()) {
+ return;
+ }
+ if (segments.size() == 1) {
+ kill(segments.get(0));
+ return;
+ }
+
+ // create a list of keys to delete
+ Map<String, List<String>> containerToKeysToDelete = new HashMap<>();
+ for (DataSegment segment : segments) {
+ Map<String, Object> loadSpec = segment.getLoadSpec();
+ final String containerName = MapUtils.getString(loadSpec,
"containerName");
+ final String blobPath = MapUtils.getString(loadSpec, "blobPath");
+ List<String> keysToDelete = containerToKeysToDelete.computeIfAbsent(
+ containerName,
+ k -> new ArrayList<>()
+ );
+ keysToDelete.add(blobPath);
+ }
+
+ boolean shouldThrowException = false;
+ for (Map.Entry<String, List<String>> containerToKeys :
containerToKeysToDelete.entrySet()) {
+ shouldThrowException = deleteBlobKeys(containerToKeys.getValue(),
containerToKeys.getKey());
+ }
+
+ if (shouldThrowException) {
+ throw new SegmentLoadingException(
+ "Couldn't delete segments from Azure. See the task logs for more
details."
+ );
+ }
+ }
+
+ private Boolean deleteBlobKeys(List<String> keysToDelete, String
containerName)
+ {
+ boolean hadException = false;
+ List<List<String>> keysChunks = Lists.partition(
+ keysToDelete,
+ MAX_MULTI_OBJECT_DELETE_SIZE
Review Comment:
hmm, its a fair point, there's no reason we wouldn't just want it in there
--
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]