forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-9031] [optimizer] Fix DataSet Union operator translation bug.
- Adds a pass over the pre-optimized plan that fixes the output strategy of union nodes to FORWARD. This closes apache#5742
- Loading branch information
1 parent
b0fbb89
commit 87ff6eb
Showing
6 changed files
with
244 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...c/main/java/org/apache/flink/optimizer/traversals/UnionParallelismAndForwardEnforcer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.flink.optimizer.traversals; | ||
|
||
import org.apache.flink.optimizer.dag.BinaryUnionNode; | ||
import org.apache.flink.optimizer.dag.DagConnection; | ||
import org.apache.flink.optimizer.dag.IterationNode; | ||
import org.apache.flink.optimizer.dag.OptimizerNode; | ||
import org.apache.flink.runtime.operators.shipping.ShipStrategyType; | ||
import org.apache.flink.util.Visitor; | ||
|
||
/** | ||
* Enforces that all union nodes have the same parallelism as their successor (there must be only one!) | ||
* and that the union node and its successor are connected by a forward ship strategy. | ||
*/ | ||
public class UnionParallelismAndForwardEnforcer implements Visitor<OptimizerNode> { | ||
|
||
@Override | ||
public boolean preVisit(OptimizerNode node) { | ||
|
||
// if the current node is a union | ||
if (node instanceof BinaryUnionNode) { | ||
int parallelism = -1; | ||
// set ship strategy of all outgoing connections to FORWARD. | ||
for (DagConnection conn : node.getOutgoingConnections()) { | ||
parallelism = conn.getTarget().getParallelism(); | ||
conn.setShipStrategy(ShipStrategyType.FORWARD); | ||
} | ||
// adjust parallelism to be same as successor | ||
node.setParallelism(parallelism); | ||
} | ||
|
||
// traverse the whole plan | ||
return true; | ||
} | ||
|
||
@Override | ||
public void postVisit(OptimizerNode node) { | ||
// if required, recurse into the step function | ||
if (node instanceof IterationNode) { | ||
((IterationNode) node).acceptForStepFunction(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters