gortiz commented on code in PR #14806:
URL: https://github.com/apache/pinot/pull/14806#discussion_r1915421089
##########
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/MultiStageBrokerRequestHandler.java:
##########
@@ -199,8 +201,15 @@ protected BrokerResponse handleRequest(long requestId,
String query, SqlNodeAndO
}
DispatchableSubPlan dispatchableSubPlan = queryPlanResult.getQueryPlan();
- Set<String> tableNames = queryPlanResult.getTableNames();
+ Set<QueryServerInstance> servers =
dispatchableSubPlan.getQueryStageList().stream()
+ .map(DispatchablePlanFragment::getServerInstances)
+ .reduce(new HashSet<QueryServerInstance>(), (all, some) -> {
+ all.addAll(some);
+ return all;
+ });
Review Comment:
nit: This is correct, but unnecessarily complex to read.
What about something like:
```
dispatchableSubPlan.getQueryStageList().stream()
.map(DispatchablePlanFragment::getServerInstances)
.reduce(new HashSet<>(), Sets::union)
.size();
```
Other options (maybe a bit more expensive, but easier to read):
```
dispatchableSubPlan.getQueryStageList().stream()
.flatMap(fragment -> fragment.getServerInstances().stream())
.distinct()
.count();
```
or
```
dispatchableSubPlan.getQueryStageList().stream()
.flatMap(fragment -> fragment.getServerInstances().stream())
.collect(Collectors.toSet())
.size();
```
--
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]