org.apache.flink.optimizer.testfunctions.DummyCoGroupFunction Java Examples
The following examples show how to use
org.apache.flink.optimizer.testfunctions.DummyCoGroupFunction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CoGroupCustomPartitioningTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testCoGroupWithTuples() { try { final Partitioner<Long> partitioner = new TestPartitionerLong(); ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple2<Long, Long>> input1 = env.fromElements(new Tuple2<Long, Long>(0L, 0L)); DataSet<Tuple3<Long, Long, Long>> input2 = env.fromElements(new Tuple3<Long, Long, Long>(0L, 0L, 0L)); input1 .coGroup(input2) .where(1).equalTo(0) .withPartitioner(partitioner) .with(new DummyCoGroupFunction<Tuple2<Long, Long>, Tuple3<Long, Long, Long>>()) .output(new DiscardingOutputFormat<Tuple2<Tuple2<Long, Long>, Tuple3<Long, Long, Long>>>()); Plan p = env.createProgramPlan(); OptimizedPlan op = compileNoStats(p); SinkPlanNode sink = op.getDataSinks().iterator().next(); DualInputPlanNode join = (DualInputPlanNode) sink.getInput().getSource(); assertEquals(ShipStrategyType.PARTITION_CUSTOM, join.getInput1().getShipStrategy()); assertEquals(ShipStrategyType.PARTITION_CUSTOM, join.getInput2().getShipStrategy()); assertEquals(partitioner, join.getInput1().getPartitioner()); assertEquals(partitioner, join.getInput2().getPartitioner()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #2
Source File: CoGroupCustomPartitioningTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testCoGroupWithPojos() { try { final Partitioner<Integer> partitioner = new TestPartitionerInt(); ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Pojo2> input1 = env.fromElements(new Pojo2()); DataSet<Pojo3> input2 = env.fromElements(new Pojo3()); input1 .coGroup(input2) .where("b").equalTo("a") .withPartitioner(partitioner) .with(new DummyCoGroupFunction<Pojo2, Pojo3>()) .output(new DiscardingOutputFormat<Tuple2<Pojo2, Pojo3>>()); Plan p = env.createProgramPlan(); OptimizedPlan op = compileNoStats(p); SinkPlanNode sink = op.getDataSinks().iterator().next(); DualInputPlanNode join = (DualInputPlanNode) sink.getInput().getSource(); assertEquals(ShipStrategyType.PARTITION_CUSTOM, join.getInput1().getShipStrategy()); assertEquals(ShipStrategyType.PARTITION_CUSTOM, join.getInput2().getShipStrategy()); assertEquals(partitioner, join.getInput1().getPartitioner()); assertEquals(partitioner, join.getInput2().getPartitioner()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #3
Source File: CoGroupCustomPartitioningTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testCoGroupWithKeySelectors() { try { final Partitioner<Integer> partitioner = new TestPartitionerInt(); ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Pojo2> input1 = env.fromElements(new Pojo2()); DataSet<Pojo3> input2 = env.fromElements(new Pojo3()); input1 .coGroup(input2) .where(new Pojo2KeySelector()).equalTo(new Pojo3KeySelector()) .withPartitioner(partitioner) .with(new DummyCoGroupFunction<Pojo2, Pojo3>()) .output(new DiscardingOutputFormat<Tuple2<Pojo2, Pojo3>>()); Plan p = env.createProgramPlan(); OptimizedPlan op = compileNoStats(p); SinkPlanNode sink = op.getDataSinks().iterator().next(); DualInputPlanNode join = (DualInputPlanNode) sink.getInput().getSource(); assertEquals(ShipStrategyType.PARTITION_CUSTOM, join.getInput1().getShipStrategy()); assertEquals(ShipStrategyType.PARTITION_CUSTOM, join.getInput2().getShipStrategy()); assertEquals(partitioner, join.getInput1().getPartitioner()); assertEquals(partitioner, join.getInput2().getPartitioner()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #4
Source File: CoGroupCustomPartitioningTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testCoGroupWithTuples() { try { final Partitioner<Long> partitioner = new TestPartitionerLong(); ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple2<Long, Long>> input1 = env.fromElements(new Tuple2<Long, Long>(0L, 0L)); DataSet<Tuple3<Long, Long, Long>> input2 = env.fromElements(new Tuple3<Long, Long, Long>(0L, 0L, 0L)); input1 .coGroup(input2) .where(1).equalTo(0) .withPartitioner(partitioner) .with(new DummyCoGroupFunction<Tuple2<Long, Long>, Tuple3<Long, Long, Long>>()) .output(new DiscardingOutputFormat<Tuple2<Tuple2<Long, Long>, Tuple3<Long, Long, Long>>>()); Plan p = env.createProgramPlan(); OptimizedPlan op = compileNoStats(p); SinkPlanNode sink = op.getDataSinks().iterator().next(); DualInputPlanNode join = (DualInputPlanNode) sink.getInput().getSource(); assertEquals(ShipStrategyType.PARTITION_CUSTOM, join.getInput1().getShipStrategy()); assertEquals(ShipStrategyType.PARTITION_CUSTOM, join.getInput2().getShipStrategy()); assertEquals(partitioner, join.getInput1().getPartitioner()); assertEquals(partitioner, join.getInput2().getPartitioner()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #5
Source File: CoGroupCustomPartitioningTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testCoGroupWithPojos() { try { final Partitioner<Integer> partitioner = new TestPartitionerInt(); ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Pojo2> input1 = env.fromElements(new Pojo2()); DataSet<Pojo3> input2 = env.fromElements(new Pojo3()); input1 .coGroup(input2) .where("b").equalTo("a") .withPartitioner(partitioner) .with(new DummyCoGroupFunction<Pojo2, Pojo3>()) .output(new DiscardingOutputFormat<Tuple2<Pojo2, Pojo3>>()); Plan p = env.createProgramPlan(); OptimizedPlan op = compileNoStats(p); SinkPlanNode sink = op.getDataSinks().iterator().next(); DualInputPlanNode join = (DualInputPlanNode) sink.getInput().getSource(); assertEquals(ShipStrategyType.PARTITION_CUSTOM, join.getInput1().getShipStrategy()); assertEquals(ShipStrategyType.PARTITION_CUSTOM, join.getInput2().getShipStrategy()); assertEquals(partitioner, join.getInput1().getPartitioner()); assertEquals(partitioner, join.getInput2().getPartitioner()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #6
Source File: CoGroupCustomPartitioningTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testCoGroupWithKeySelectors() { try { final Partitioner<Integer> partitioner = new TestPartitionerInt(); ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Pojo2> input1 = env.fromElements(new Pojo2()); DataSet<Pojo3> input2 = env.fromElements(new Pojo3()); input1 .coGroup(input2) .where(new Pojo2KeySelector()).equalTo(new Pojo3KeySelector()) .withPartitioner(partitioner) .with(new DummyCoGroupFunction<Pojo2, Pojo3>()) .output(new DiscardingOutputFormat<Tuple2<Pojo2, Pojo3>>()); Plan p = env.createProgramPlan(); OptimizedPlan op = compileNoStats(p); SinkPlanNode sink = op.getDataSinks().iterator().next(); DualInputPlanNode join = (DualInputPlanNode) sink.getInput().getSource(); assertEquals(ShipStrategyType.PARTITION_CUSTOM, join.getInput1().getShipStrategy()); assertEquals(ShipStrategyType.PARTITION_CUSTOM, join.getInput2().getShipStrategy()); assertEquals(partitioner, join.getInput1().getPartitioner()); assertEquals(partitioner, join.getInput2().getPartitioner()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #7
Source File: CoGroupCustomPartitioningTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testCoGroupWithTuples() { try { final Partitioner<Long> partitioner = new TestPartitionerLong(); ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple2<Long, Long>> input1 = env.fromElements(new Tuple2<Long, Long>(0L, 0L)); DataSet<Tuple3<Long, Long, Long>> input2 = env.fromElements(new Tuple3<Long, Long, Long>(0L, 0L, 0L)); input1 .coGroup(input2) .where(1).equalTo(0) .withPartitioner(partitioner) .with(new DummyCoGroupFunction<Tuple2<Long, Long>, Tuple3<Long, Long, Long>>()) .output(new DiscardingOutputFormat<Tuple2<Tuple2<Long, Long>, Tuple3<Long, Long, Long>>>()); Plan p = env.createProgramPlan(); OptimizedPlan op = compileNoStats(p); SinkPlanNode sink = op.getDataSinks().iterator().next(); DualInputPlanNode join = (DualInputPlanNode) sink.getInput().getSource(); assertEquals(ShipStrategyType.PARTITION_CUSTOM, join.getInput1().getShipStrategy()); assertEquals(ShipStrategyType.PARTITION_CUSTOM, join.getInput2().getShipStrategy()); assertEquals(partitioner, join.getInput1().getPartitioner()); assertEquals(partitioner, join.getInput2().getPartitioner()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #8
Source File: CoGroupCustomPartitioningTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testCoGroupWithPojos() { try { final Partitioner<Integer> partitioner = new TestPartitionerInt(); ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Pojo2> input1 = env.fromElements(new Pojo2()); DataSet<Pojo3> input2 = env.fromElements(new Pojo3()); input1 .coGroup(input2) .where("b").equalTo("a") .withPartitioner(partitioner) .with(new DummyCoGroupFunction<Pojo2, Pojo3>()) .output(new DiscardingOutputFormat<Tuple2<Pojo2, Pojo3>>()); Plan p = env.createProgramPlan(); OptimizedPlan op = compileNoStats(p); SinkPlanNode sink = op.getDataSinks().iterator().next(); DualInputPlanNode join = (DualInputPlanNode) sink.getInput().getSource(); assertEquals(ShipStrategyType.PARTITION_CUSTOM, join.getInput1().getShipStrategy()); assertEquals(ShipStrategyType.PARTITION_CUSTOM, join.getInput2().getShipStrategy()); assertEquals(partitioner, join.getInput1().getPartitioner()); assertEquals(partitioner, join.getInput2().getPartitioner()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #9
Source File: CoGroupCustomPartitioningTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testCoGroupWithKeySelectors() { try { final Partitioner<Integer> partitioner = new TestPartitionerInt(); ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Pojo2> input1 = env.fromElements(new Pojo2()); DataSet<Pojo3> input2 = env.fromElements(new Pojo3()); input1 .coGroup(input2) .where(new Pojo2KeySelector()).equalTo(new Pojo3KeySelector()) .withPartitioner(partitioner) .with(new DummyCoGroupFunction<Pojo2, Pojo3>()) .output(new DiscardingOutputFormat<Tuple2<Pojo2, Pojo3>>()); Plan p = env.createProgramPlan(); OptimizedPlan op = compileNoStats(p); SinkPlanNode sink = op.getDataSinks().iterator().next(); DualInputPlanNode join = (DualInputPlanNode) sink.getInput().getSource(); assertEquals(ShipStrategyType.PARTITION_CUSTOM, join.getInput1().getShipStrategy()); assertEquals(ShipStrategyType.PARTITION_CUSTOM, join.getInput2().getShipStrategy()); assertEquals(partitioner, join.getInput1().getPartitioner()); assertEquals(partitioner, join.getInput2().getPartitioner()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #10
Source File: BranchingPlansCompilerTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * <pre> * SINK * | * COGROUP * +---/ \----+ * / \ * / MATCH10 * / | \ * / | MATCH9 * MATCH5 | | \ * | \ | | MATCH8 * | MATCH4 | | | \ * | | \ | | | MATCH7 * | | MATCH3 | | | | \ * | | | \ | | | | MATCH6 * | | | MATCH2 | | | | | | * | | | | \ +--+--+--+--+--+ * | | | | MATCH1 MAP * \ | | | | | /-----------/ * (DATA SOURCE ONE) * </pre> */ @Test public void testBranchingSourceMultipleTimes() { try { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(DEFAULT_PARALLELISM); DataSet<Tuple2<Long, Long>> source = env.generateSequence(1, 10000000) .map(new Duplicator<Long>()); DataSet<Tuple2<Long, Long>> joined1 = source.join(source).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined2 = source.join(joined1).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined3 = source.join(joined2).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined4 = source.join(joined3).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined5 = source.join(joined4).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> mapped = source.map( new MapFunction<Tuple2<Long, Long>, Tuple2<Long, Long>>() { @Override public Tuple2<Long, Long> map(Tuple2<Long, Long> value) { return null; } }); DataSet<Tuple2<Long, Long>> joined6 = mapped.join(mapped).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined7 = mapped.join(joined6).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined8 = mapped.join(joined7).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined9 = mapped.join(joined8).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined10 = mapped.join(joined9).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); joined5.coGroup(joined10) .where(1).equalTo(1) .with(new DummyCoGroupFunction<Tuple2<Long, Long>, Tuple2<Long, Long>>()) .output(new DiscardingOutputFormat<Tuple2<Tuple2<Long, Long>, Tuple2<Long, Long>>>()); Plan plan = env.createProgramPlan(); OptimizedPlan oPlan = compileNoStats(plan); new JobGraphGenerator().compileJobGraph(oPlan); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #11
Source File: BranchingPlansCompilerTest.java From flink with Apache License 2.0 | 4 votes |
/** * <pre> * SINK * | * COGROUP * +---/ \----+ * / \ * / MATCH10 * / | \ * / | MATCH9 * MATCH5 | | \ * | \ | | MATCH8 * | MATCH4 | | | \ * | | \ | | | MATCH7 * | | MATCH3 | | | | \ * | | | \ | | | | MATCH6 * | | | MATCH2 | | | | | | * | | | | \ +--+--+--+--+--+ * | | | | MATCH1 MAP * \ | | | | | /-----------/ * (DATA SOURCE ONE) * </pre> */ @Test public void testBranchingSourceMultipleTimes() { try { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(DEFAULT_PARALLELISM); DataSet<Tuple2<Long, Long>> source = env.generateSequence(1, 10000000) .map(new Duplicator<Long>()); DataSet<Tuple2<Long, Long>> joined1 = source.join(source).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined2 = source.join(joined1).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined3 = source.join(joined2).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined4 = source.join(joined3).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined5 = source.join(joined4).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> mapped = source.map( new MapFunction<Tuple2<Long, Long>, Tuple2<Long, Long>>() { @Override public Tuple2<Long, Long> map(Tuple2<Long, Long> value) { return null; } }); DataSet<Tuple2<Long, Long>> joined6 = mapped.join(mapped).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined7 = mapped.join(joined6).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined8 = mapped.join(joined7).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined9 = mapped.join(joined8).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined10 = mapped.join(joined9).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); joined5.coGroup(joined10) .where(1).equalTo(1) .with(new DummyCoGroupFunction<Tuple2<Long, Long>, Tuple2<Long, Long>>()) .output(new DiscardingOutputFormat<Tuple2<Tuple2<Long, Long>, Tuple2<Long, Long>>>()); Plan plan = env.createProgramPlan(); OptimizedPlan oPlan = compileNoStats(plan); new JobGraphGenerator().compileJobGraph(oPlan); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #12
Source File: BranchingPlansCompilerTest.java From flink with Apache License 2.0 | 4 votes |
/** * <pre> * SINK * | * COGROUP * +---/ \----+ * / \ * / MATCH10 * / | \ * / | MATCH9 * MATCH5 | | \ * | \ | | MATCH8 * | MATCH4 | | | \ * | | \ | | | MATCH7 * | | MATCH3 | | | | \ * | | | \ | | | | MATCH6 * | | | MATCH2 | | | | | | * | | | | \ +--+--+--+--+--+ * | | | | MATCH1 MAP * \ | | | | | /-----------/ * (DATA SOURCE ONE) * </pre> */ @Test public void testBranchingSourceMultipleTimes() { try { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(DEFAULT_PARALLELISM); DataSet<Tuple2<Long, Long>> source = env.generateSequence(1, 10000000) .map(new Duplicator<Long>()); DataSet<Tuple2<Long, Long>> joined1 = source.join(source).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined2 = source.join(joined1).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined3 = source.join(joined2).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined4 = source.join(joined3).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined5 = source.join(joined4).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> mapped = source.map( new MapFunction<Tuple2<Long, Long>, Tuple2<Long, Long>>() { @Override public Tuple2<Long, Long> map(Tuple2<Long, Long> value) { return null; } }); DataSet<Tuple2<Long, Long>> joined6 = mapped.join(mapped).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined7 = mapped.join(joined6).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined8 = mapped.join(joined7).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined9 = mapped.join(joined8).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); DataSet<Tuple2<Long, Long>> joined10 = mapped.join(joined9).where(0).equalTo(0) .with(new DummyFlatJoinFunction<Tuple2<Long, Long>>()); joined5.coGroup(joined10) .where(1).equalTo(1) .with(new DummyCoGroupFunction<Tuple2<Long, Long>, Tuple2<Long, Long>>()) .output(new DiscardingOutputFormat<Tuple2<Tuple2<Long, Long>, Tuple2<Long, Long>>>()); Plan plan = env.createProgramPlan(); OptimizedPlan oPlan = compileNoStats(plan); new JobGraphGenerator().compileJobGraph(oPlan); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }