himanish-star commented on code in PR #15725: URL: https://github.com/apache/pinot/pull/15725#discussion_r2098419990
########## pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java: ########## @@ -3250,18 +3250,29 @@ public void toggleQueryQuotaStateForBroker(String brokerInstanceName, String sta * the ideal state because they are not supposed to be served. */ public Map<String, List<String>> getServerToSegmentsMap(String tableNameWithType) { - return getServerToSegmentsMap(tableNameWithType, null); + return getServerToSegmentsMap(tableNameWithType, null, true); } - public Map<String, List<String>> getServerToSegmentsMap(String tableNameWithType, @Nullable String targetServer) { + public Map<String, List<String>> getServerToSegmentsMap(String tableNameWithType, @Nullable String targetServer, + boolean includeReplacedSegments) { Map<String, List<String>> serverToSegmentsMap = new TreeMap<>(); IdealState idealState = _helixAdmin.getResourceIdealState(_helixClusterName, tableNameWithType); if (idealState == null) { throw new IllegalStateException("Ideal state does not exist for table: " + tableNameWithType); } - for (Map.Entry<String, Map<String, String>> entry : idealState.getRecord().getMapFields().entrySet()) { - String segmentName = entry.getKey(); - for (Map.Entry<String, String> instanceStateEntry : entry.getValue().entrySet()) { + + Map<String, Map<String, String>> idealStateMap = idealState.getRecord().getMapFields(); + Set<String> segments = idealStateMap.keySet(); + + if (!includeReplacedSegments) { + SegmentLineage segmentLineage = SegmentLineageAccessHelper + .getSegmentLineage(getPropertyStore(), tableNameWithType); + SegmentLineageUtils.filterSegmentsBasedOnLineageInPlace(segments, segmentLineage); + } + + for (String segmentName : segments) { + Set<Map.Entry<String, String>> entry = idealStateMap.get(segmentName).entrySet(); Review Comment: ok -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org