From ada3ae08dfc432f34e4ef1ec87f9800c91ba2c54 Mon Sep 17 00:00:00 2001 From: Gian Merlino Date: Fri, 4 Mar 2022 08:06:20 -0800 Subject: [PATCH] Retain order in TaskReport. (#12005) --- .../java/org/apache/druid/indexing/common/TaskReport.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/TaskReport.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/TaskReport.java index 3cee6f2aa5c..5e2f5b6c740 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/TaskReport.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/TaskReport.java @@ -22,7 +22,7 @@ package org.apache.druid.indexing.common; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; /** @@ -44,9 +44,13 @@ public interface TaskReport */ Object getPayload(); + /** + * Returns an order-preserving map that is suitable for passing into {@link TaskReportFileWriter#write}. + */ static Map buildTaskReports(TaskReport... taskReports) { - Map taskReportMap = new HashMap<>(); + // Use LinkedHashMap to preserve order of the reports. + Map taskReportMap = new LinkedHashMap<>(); for (TaskReport taskReport : taskReports) { taskReportMap.put(taskReport.getReportKey(), taskReport); }