Search in sources :

Example 6 with IdentityJoiner

use of org.apache.flink.optimizer.testfunctions.IdentityJoiner in project flink by apache.

the class BranchingPlansCompilerTest method testClosureDeltaIteration.

/**
 * <pre>
 *       (SRC A)         (SRC B)          (SRC C)
 *      /       \       /                /       \
 *  (SINK 1) (DELTA ITERATION)          |     (SINK 2)
 *             /    |   \               /
 *         (SINK 3) |   (CROSS => NEXT WORKSET)
 *                  |             |
 *                (JOIN => SOLUTION SET DELTA)
 * </pre>
 */
@Test
public void testClosureDeltaIteration() {
    ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    env.setParallelism(DEFAULT_PARALLELISM);
    DataSet<Tuple2<Long, Long>> sourceA = env.generateSequence(0, 1).map(new Duplicator<Long>());
    DataSet<Tuple2<Long, Long>> sourceB = env.generateSequence(0, 1).map(new Duplicator<Long>());
    DataSet<Tuple2<Long, Long>> sourceC = env.generateSequence(0, 1).map(new Duplicator<Long>());
    sourceA.output(new DiscardingOutputFormat<Tuple2<Long, Long>>());
    sourceC.output(new DiscardingOutputFormat<Tuple2<Long, Long>>());
    DeltaIteration<Tuple2<Long, Long>, Tuple2<Long, Long>> loop = sourceA.iterateDelta(sourceB, 10, 0);
    DataSet<Tuple2<Long, Long>> workset = loop.getWorkset().cross(sourceB).with(new IdentityCrosser<Tuple2<Long, Long>>()).name("Next work set");
    DataSet<Tuple2<Long, Long>> delta = workset.join(loop.getSolutionSet()).where(0).equalTo(0).with(new IdentityJoiner<Tuple2<Long, Long>>()).name("Solution set delta");
    DataSet<Tuple2<Long, Long>> result = loop.closeWith(delta, workset);
    result.output(new DiscardingOutputFormat<Tuple2<Long, Long>>());
    Plan plan = env.createProgramPlan();
    try {
        compileNoStats(plan);
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail(e.getMessage());
    }
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Tuple2(org.apache.flink.api.java.tuple.Tuple2) IdentityCrosser(org.apache.flink.optimizer.testfunctions.IdentityCrosser) IdentityJoiner(org.apache.flink.optimizer.testfunctions.IdentityJoiner) Plan(org.apache.flink.api.common.Plan) OptimizedPlan(org.apache.flink.optimizer.plan.OptimizedPlan) Test(org.junit.Test)

Aggregations

ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)6 IdentityJoiner (org.apache.flink.optimizer.testfunctions.IdentityJoiner)6 Plan (org.apache.flink.api.common.Plan)5 OptimizedPlan (org.apache.flink.optimizer.plan.OptimizedPlan)5 Test (org.junit.Test)5 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)3 JobGraphGenerator (org.apache.flink.optimizer.plantranslate.JobGraphGenerator)3 IdentityCrosser (org.apache.flink.optimizer.testfunctions.IdentityCrosser)2 IdentityGroupReducer (org.apache.flink.optimizer.testfunctions.IdentityGroupReducer)2 IdentityMapper (org.apache.flink.optimizer.testfunctions.IdentityMapper)2 DiscardingOutputFormat (org.apache.flink.api.java.io.DiscardingOutputFormat)1 JoinOperator (org.apache.flink.api.java.operators.JoinOperator)1 Channel (org.apache.flink.optimizer.plan.Channel)1 DualInputPlanNode (org.apache.flink.optimizer.plan.DualInputPlanNode)1 PlanNode (org.apache.flink.optimizer.plan.PlanNode)1 SingleInputPlanNode (org.apache.flink.optimizer.plan.SingleInputPlanNode)1 SinkPlanNode (org.apache.flink.optimizer.plan.SinkPlanNode)1 IdentityCoGrouper (org.apache.flink.optimizer.testfunctions.IdentityCoGrouper)1