jackjlli commented on code in PR #10754:
URL: https://github.com/apache/pinot/pull/10754#discussion_r1197228815


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java:
##########
@@ -872,6 +874,24 @@ public List<SegmentZKMetadata> 
getSegmentsZKMetadata(String tableNameWithType) {
     return ZKMetadataProvider.getSegmentsZKMetadata(_propertyStore, 
tableNameWithType);
   }
 
+  public List<String> getLastLLCCompletedSegments(String tableNameWithType) {
+    Map<Integer, String> partitionIdToLastLLCCompletedSegmentMap = new 
HashMap<>();
+    for (SegmentZKMetadata segMetadata : 
getSegmentsZKMetadata(tableNameWithType)) {
+      if 
(SegmentName.isLowLevelConsumerSegmentName(segMetadata.getSegmentName())
+          && segMetadata.getStatus() == 
CommonConstants.Segment.Realtime.Status.DONE) {
+        LLCSegmentName llcName = 
LLCSegmentName.of(segMetadata.getSegmentName());
+        int partitionGroupId = llcName.getPartitionGroupId();
+        int sequenceNumber = llcName.getSequenceNumber();
+        String lastCompletedSegName = 
partitionIdToLastLLCCompletedSegmentMap.get(partitionGroupId);
+        if (lastCompletedSegName == null
+            || LLCSegmentName.of(lastCompletedSegName).getSequenceNumber() < 
sequenceNumber) {
+          partitionIdToLastLLCCompletedSegmentMap.put(partitionGroupId, 
segMetadata.getSegmentName());
+        }
+      }
+    }
+    return new ArrayList<>(partitionIdToLastLLCCompletedSegmentMap.values());

Review Comment:
   you can just return `partitionIdToLastLLCCompletedSegmentMap.values()`, no 
need to wrap with another array list.



##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java:
##########
@@ -872,6 +874,24 @@ public List<SegmentZKMetadata> 
getSegmentsZKMetadata(String tableNameWithType) {
     return ZKMetadataProvider.getSegmentsZKMetadata(_propertyStore, 
tableNameWithType);
   }
 
+  public List<String> getLastLLCCompletedSegments(String tableNameWithType) {
+    Map<Integer, String> partitionIdToLastLLCCompletedSegmentMap = new 
HashMap<>();
+    for (SegmentZKMetadata segMetadata : 
getSegmentsZKMetadata(tableNameWithType)) {

Review Comment:
   nit: use `ZKMetadataProvider.getLLCRealtimeSegments()` if you want to just 
get the metadata for realtime segments.



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