[
https://issues.apache.org/jira/browse/DRILL-5286?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15942171#comment-15942171
]
ASF GitHub Bot commented on DRILL-5286:
---------------------------------------
Github user chunhui-shi commented on a diff in the pull request:
https://github.com/apache/drill/pull/797#discussion_r108052498
--- Diff:
exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/SubsetTransformer.java
---
@@ -45,15 +48,20 @@ public RelTraitSet newTraitSet(RelTrait... traits) {
}
- boolean go(T n, RelNode candidateSet) throws E {
+ public boolean go(T n, RelNode candidateSet) throws E {
if ( !(candidateSet instanceof RelSubset) ) {
return false;
}
boolean transform = false;
+ Set<RelNode> transformedRels = Sets.newHashSet();
for (RelNode rel : ((RelSubset)candidateSet).getRelList()) {
if (isPhysical(rel)) {
RelNode newRel = RelOptRule.convert(candidateSet,
rel.getTraitSet().plus(Prel.DRILL_PHYSICAL));
+ if(transformedRels.contains(newRel)) {
--- End diff --
this " if(transformedRels.contains(newRel))" is to check if the newRel is
the _same_ object we got before, it is not to check a 'equal' node. So no
hashCode or equal function required.
And yes, I did step into this code and it is doing what we want: for the
same node(n) to be converted in below convertChild() and the same equivalent
set(newRel), we don't need to run the rule again, since we are going to get the
same result, and that result will be added to the same set. So we are very sure
we could skip convertChild() for this pair of input(n, newRel) since this has
been called before.
In some cases it can reduce the same rule from running 16 times to 4 times
and saved hundreds ms.
> When rel and target candidate set is the same, planner should not need to do
> convert for the relNode since it must have been done
> ---------------------------------------------------------------------------------------------------------------------------------
>
> Key: DRILL-5286
> URL: https://issues.apache.org/jira/browse/DRILL-5286
> Project: Apache Drill
> Issue Type: Bug
> Reporter: Chunhui Shi
> Assignee: Chunhui Shi
>
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)