kfaraz commented on code in PR #19532:
URL: https://github.com/apache/druid/pull/19532#discussion_r3593547411


##########
server/src/main/java/org/apache/druid/server/coordinator/DruidCoordinator.java:
##########
@@ -801,26 +803,46 @@ public DruidCoordinatorRuntimeParams 
run(DruidCoordinatorRuntimeParams params)
     {
       // Collect stats for unavailable and under-replicated segments
       final CoordinatorRunStats stats = params.getCoordinatorStats();
-      getDatasourceToUnavailableSegmentCount().forEach(
-          (dataSource, numUnavailable) -> stats.add(
-              Stats.Segments.UNAVAILABLE,
-              RowKey.of(Dimension.DATASOURCE, dataSource),
-              numUnavailable
-          )
-      );
-      getTierToDatasourceToUnderReplicatedCount(false).forEach(
-          (tier, countsPerDatasource) -> countsPerDatasource.forEach(
-              (dataSource, underReplicatedCount) ->
-                  stats.addToSegmentStat(Stats.Segments.UNDER_REPLICATED, 
tier, dataSource, underReplicatedCount)
-          )
-      );
-      getDatasourceToDeepStorageQueryOnlySegmentCount().forEach(
-          (dataSource, numDeepStorageOnly) -> stats.add(
-              Stats.Segments.DEEP_STORAGE_ONLY,
-              RowKey.of(Dimension.DATASOURCE, dataSource),
-              numDeepStorageOnly
-          )
-      );
+
+      final Object2IntMap<String> dsToUnavailable;
+      final Map<String, Object2LongMap<String>> tierToDsToUnderRepl;
+      final Object2IntMap<String> dsToDeepStorageOnly;
+
+      if (segmentReplicationStatus == null) {
+        dsToUnavailable = Object2IntMaps.emptyMap();
+        tierToDsToUnderRepl = Collections.emptyMap();
+        dsToDeepStorageOnly = Object2IntMaps.emptyMap();
+      } else {
+        // Single fused pass replaces three independent full iterations over
+        // metadataManager.iterateAllUsedSegments(). ignoreMissingServers=true 
replicates
+        // the !false inversion inside computeUnderReplicated(segments, false).

Review Comment:
   simplify the comment. details may be found in the javadoc of 
`computeSegmentStats` itself.
   ```suggestion
           // Compute unavailable, under-replicated, deep-storage only counts 
in a single pass
   ```



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