Jackie-Jiang commented on code in PR #20313:
URL: https://github.com/apache/pinot/pull/20313#discussion_r4673410771


##########
pinot-broker/src/main/java/org/apache/pinot/broker/routing/instanceselector/SegmentStates.java:
##########
@@ -124,6 +124,18 @@ public boolean isUnavailable(int groupId) {
     return _routings[groupId].getNumCandidates() == 0 && 
!_segmentGroups._groups[groupId]._new;
   }
 
+  /// Returns whether the given segment is a new segment that an enabled 
instance might not have loaded yet: it is not
+  /// online on all of its enabled candidates, or it is not tracked yet, which 
a segment only is while it is being
+  /// added, because the routing components learn about it one after another.
+  public boolean isNewAndNotFullyOnline(String segment) {
+    int groupId = getGroupId(segment);
+    if (groupId == UNKNOWN_SEGMENT) {
+      return true;
+    }
+    GroupRouting routing = _routings[groupId];
+    return routing.getNumCandidates() > 0 ? !routing._allOnline : 
_segmentGroups._groups[groupId]._new;

Review Comment:
   Done. `selectOnAllInstances` now reads the clock once, and 
`isNewAndNotFullyOnline` checks the creation time of the segment against the 
new segment expiration time. After the limit the segment is returned as a 
required segment, also when the assignment has not changed since. A segment the 
selector does not track yet stays optional, because that only lasts while the 
routing components are being updated.
   



##########
pinot-core/src/main/java/org/apache/pinot/core/routing/SegmentsToQuery.java:
##########
@@ -47,4 +60,26 @@ public List<String> getSegments() {
   public List<String> getOptionalSegments() {
     return _optionalSegments;
   }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (!(o instanceof SegmentsToQuery)) {
+      return false;
+    }
+    SegmentsToQuery that = (SegmentsToQuery) o;
+    return _segments.equals(that._segments) && 
_optionalSegments.equals(that._optionalSegments);

Review Comment:
   Done. The constructor now turns a null `optionalSegments` into `List.of()`.
   



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