himanish-star commented on code in PR #15725:
URL: https://github.com/apache/pinot/pull/15725#discussion_r2095742953


##########
pinot-controller/src/main/java/org/apache/pinot/controller/util/TableSizeReader.java:
##########
@@ -241,9 +248,40 @@ static public class SegmentSizeDetails {
     public Map<String, SegmentSizeInfo> _serverInfo = new HashMap<>();
   }
 
+  private Map<String, List<String>> getServerToSegmentsMap(final String 
tableNameWithType,
+      final Boolean showReplacedSegments) {
+    Map<String, List<String>> serverToSegmentsMap = 
_helixResourceManager.getServerToSegmentsMap(tableNameWithType);
+
+    Set<String> segments = new HashSet<>();
+    for (List<String> segmentList : serverToSegmentsMap.values()) {
+      segments.addAll(segmentList);
+    }
+
+    // Filter out replaced segments
+    if (!showReplacedSegments) {
+      SegmentLineage segmentLineage = SegmentLineageAccessHelper
+          .getSegmentLineage(_helixResourceManager.getPropertyStore(), 
tableNameWithType);
+      SegmentLineageUtils.filterSegmentsBasedOnLineageInPlace(segments, 
segmentLineage);
+    }
+
+    for (Iterator<Map.Entry<String, List<String>>> it = 
serverToSegmentsMap.entrySet().iterator(); it.hasNext(); ) {
+      Map.Entry<String, List<String>> entry = it.next();
+      List<String> filtered = entry.getValue().stream()
+          .filter(segments::contains)
+          .collect(Collectors.toList());
+      if (filtered.isEmpty()) {
+        it.remove();
+      } else {
+        entry.setValue(filtered);
+      }
+    }
+
+    return serverToSegmentsMap;
+  }
+
   public TableSubTypeSizeDetails getTableSubtypeSize(String tableNameWithType, 
int timeoutMs)
       throws InvalidConfigException {
-    Map<String, List<String>> serverToSegmentsMap = 
_helixResourceManager.getServerToSegmentsMap(tableNameWithType);
+    Map<String, List<String>> serverToSegmentsMap = 
getServerToSegmentsMap(tableNameWithType, false);

Review Comment:
   Moved!



##########
pinot-controller/src/main/java/org/apache/pinot/controller/util/TableSizeReader.java:
##########
@@ -241,9 +248,40 @@ static public class SegmentSizeDetails {
     public Map<String, SegmentSizeInfo> _serverInfo = new HashMap<>();
   }
 
+  private Map<String, List<String>> getServerToSegmentsMap(final String 
tableNameWithType,

Review Comment:
   Removed



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

Reply via email to