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


##########
pinot-core/src/main/java/org/apache/pinot/core/query/request/ServerQueryRequest.java:
##########
@@ -205,10 +205,33 @@ public String getTableNameWithType() {
     return _queryContext.getTableName();
   }
 
+  /// The segments assigned to this worker, or null when the request carries 
them per referenced table in
+  /// [#getTableSegmentsContexts()] instead, as it does for a logical table. 
Callers must check that one first, the
+  /// way `ServerQueryExecutorV1Impl` does, or use [#hasSegmentsToQuery()] 
when all they need is whether this
+  /// request has any segment at all.
+  @Nullable
   public List<String> getSegmentsToQuery() {
     return _segmentsToQuery;
   }
 
+  /// Whether this request has at least one segment to read, whichever of the 
two representations carries them.
+  ///
+  /// A request holds its segments either flat in [#getSegmentsToQuery()], for 
a plain table, or grouped per
+  /// referenced table in [#getTableSegmentsContexts()], for a logical table; 
the other one is null. Resolving that
+  /// here keeps callers that only need the question answered from having to 
know which representation applies.
+  public boolean hasSegmentsToQuery() {
+    if (_tableSegmentsContexts != null) {
+      for (TableSegmentsContext tableSegmentsContext : _tableSegmentsContexts) 
{
+        List<String> segments = tableSegmentsContext.getSegments();
+        if (segments != null && !segments.isEmpty()) {

Review Comment:
   (minor) Use `CollectionUtils.isNotEmpty()`, same for other places



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