deniskuzZ commented on code in PR #6806:
URL: https://github.com/apache/hive/pull/6806#discussion_r4083081645
##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/SharedWorkOptimizer.java:
##########
@@ -2068,44 +2068,43 @@ private static Set<Operator<?>>
findAscendantOperators(SharedWorkOptimizerCache
return visited;
}
- private static Set<Operator<?>> findDescendantWorkOperators(ParseContext
pctx,
+ @VisibleForTesting
+ static Set<Operator<?>> findDescendantWorkOperators(ParseContext pctx,
SharedWorkOptimizerCache optimizerCache, Operator<?> start,
Set<Operator<?>> excludeOps) {
- // Find operators in work
- Set<Operator<?>> workOps = findWorkOperators(optimizerCache, start);
- // Gather output works operators
- Set<Operator<?>> result = new HashSet<Operator<?>>();
- Set<Operator<?>> set;
- while (!workOps.isEmpty()) {
- set = new HashSet<Operator<?>>();
- for (Operator<?> op : workOps) {
- if (excludeOps.contains(op)) {
- continue;
- }
- if (op instanceof ReduceSinkOperator) {
- if (op.getChildOperators() != null) {
- // All children of RS are descendants
- for (Operator<?> child : op.getChildOperators()) {
- set.addAll(findWorkOperators(optimizerCache, child));
- }
- }
- // Semijoin DPP work is considered a descendant because work needs
- // to finish for it to execute
- SemiJoinBranchInfo sjbi = pctx.getRsToSemiJoinBranchInfo().get(op);
- if (sjbi != null) {
- set.addAll(findWorkOperators(optimizerCache, sjbi.getTsOp()));
+
+ // Gather input operators
+ Set<Operator<?>> startWorkOperators = findWorkOperators(optimizerCache,
start);
+ Set<Operator<?>> visited = new HashSet<>();
+ Queue<Operator<?>> remaining = new LinkedList<>(startWorkOperators);
+ while (!remaining.isEmpty()) {
+ Operator<?> op = remaining.poll();
+ if (!visited.add(op) || excludeOps.contains(op)) {
Review Comment:
excluded operators (excludeOps) are still reported (included into visited)
but not traversed , is that ok ?
--
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]