org.apache.flink.optimizer.testfunctions.IdentityKeyExtractor Java Examples
The following examples show how to use
org.apache.flink.optimizer.testfunctions.IdentityKeyExtractor.
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: NestedIterationsTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testBulkIterationInClosure() { try { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Long> data1 = env.generateSequence(1, 100); DataSet<Long> data2 = env.generateSequence(1, 100); IterativeDataSet<Long> firstIteration = data1.iterate(100); DataSet<Long> firstResult = firstIteration.closeWith(firstIteration.map(new IdentityMapper<Long>())); IterativeDataSet<Long> mainIteration = data2.map(new IdentityMapper<Long>()).iterate(100); DataSet<Long> joined = mainIteration.join(firstResult) .where(new IdentityKeyExtractor<Long>()).equalTo(new IdentityKeyExtractor<Long>()) .with(new DummyFlatJoinFunction<Long>()); DataSet<Long> mainResult = mainIteration.closeWith(joined); mainResult.output(new DiscardingOutputFormat<Long>()); Plan p = env.createProgramPlan(); // optimizer should be able to translate this OptimizedPlan op = compileNoStats(p); // job graph generator should be able to translate this new JobGraphGenerator().compileJobGraph(op); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #2
Source File: BranchingPlansCompilerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * <pre> * +---------Iteration-------+ * | | * /--map--< >----\ | * / | \ /-------< >---sink * src-map | join------/ | * \ | / | * \ +-----/-------------------+ * \ / * \--reduce--/ * </pre> */ @Test public void testIterationWithStaticInput() { try { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(100); DataSet<Long> source = env.generateSequence(1, 1000000); DataSet<Long> mapped = source.map(new IdentityMapper<Long>()); DataSet<Long> reduced = source.groupBy(new IdentityKeyExtractor<Long>()).reduce(new SelectOneReducer<Long>()); IterativeDataSet<Long> iteration = mapped.iterate(10); iteration.closeWith( iteration.join(reduced) .where(new IdentityKeyExtractor<Long>()) .equalTo(new IdentityKeyExtractor<Long>()) .with(new DummyFlatJoinFunction<Long>())) .output(new DiscardingOutputFormat<Long>()); compileNoStats(env.createProgramPlan()); } catch(Exception e){ e.printStackTrace(); fail(e.getMessage()); } }
Example #3
Source File: NestedIterationsTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testBulkIterationInClosure() { try { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Long> data1 = env.generateSequence(1, 100); DataSet<Long> data2 = env.generateSequence(1, 100); IterativeDataSet<Long> firstIteration = data1.iterate(100); DataSet<Long> firstResult = firstIteration.closeWith(firstIteration.map(new IdentityMapper<Long>())); IterativeDataSet<Long> mainIteration = data2.map(new IdentityMapper<Long>()).iterate(100); DataSet<Long> joined = mainIteration.join(firstResult) .where(new IdentityKeyExtractor<Long>()).equalTo(new IdentityKeyExtractor<Long>()) .with(new DummyFlatJoinFunction<Long>()); DataSet<Long> mainResult = mainIteration.closeWith(joined); mainResult.output(new DiscardingOutputFormat<Long>()); Plan p = env.createProgramPlan(); // optimizer should be able to translate this OptimizedPlan op = compileNoStats(p); // job graph generator should be able to translate this new JobGraphGenerator().compileJobGraph(op); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #4
Source File: BranchingPlansCompilerTest.java From flink with Apache License 2.0 | 5 votes |
/** * <pre> * +---------Iteration-------+ * | | * /--map--< >----\ | * / | \ /-------< >---sink * src-map | join------/ | * \ | / | * \ +-----/-------------------+ * \ / * \--reduce--/ * </pre> */ @Test public void testIterationWithStaticInput() { try { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(100); DataSet<Long> source = env.generateSequence(1, 1000000); DataSet<Long> mapped = source.map(new IdentityMapper<Long>()); DataSet<Long> reduced = source.groupBy(new IdentityKeyExtractor<Long>()).reduce(new SelectOneReducer<Long>()); IterativeDataSet<Long> iteration = mapped.iterate(10); iteration.closeWith( iteration.join(reduced) .where(new IdentityKeyExtractor<Long>()) .equalTo(new IdentityKeyExtractor<Long>()) .with(new DummyFlatJoinFunction<Long>())) .output(new DiscardingOutputFormat<Long>()); compileNoStats(env.createProgramPlan()); } catch(Exception e){ e.printStackTrace(); fail(e.getMessage()); } }
Example #5
Source File: NestedIterationsTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testBulkIterationInClosure() { try { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Long> data1 = env.generateSequence(1, 100); DataSet<Long> data2 = env.generateSequence(1, 100); IterativeDataSet<Long> firstIteration = data1.iterate(100); DataSet<Long> firstResult = firstIteration.closeWith(firstIteration.map(new IdentityMapper<Long>())); IterativeDataSet<Long> mainIteration = data2.map(new IdentityMapper<Long>()).iterate(100); DataSet<Long> joined = mainIteration.join(firstResult) .where(new IdentityKeyExtractor<Long>()).equalTo(new IdentityKeyExtractor<Long>()) .with(new DummyFlatJoinFunction<Long>()); DataSet<Long> mainResult = mainIteration.closeWith(joined); mainResult.output(new DiscardingOutputFormat<Long>()); Plan p = env.createProgramPlan(); // optimizer should be able to translate this OptimizedPlan op = compileNoStats(p); // job graph generator should be able to translate this new JobGraphGenerator().compileJobGraph(op); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #6
Source File: BranchingPlansCompilerTest.java From flink with Apache License 2.0 | 5 votes |
/** * <pre> * +---------Iteration-------+ * | | * /--map--< >----\ | * / | \ /-------< >---sink * src-map | join------/ | * \ | / | * \ +-----/-------------------+ * \ / * \--reduce--/ * </pre> */ @Test public void testIterationWithStaticInput() { try { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(100); DataSet<Long> source = env.generateSequence(1, 1000000); DataSet<Long> mapped = source.map(new IdentityMapper<Long>()); DataSet<Long> reduced = source.groupBy(new IdentityKeyExtractor<Long>()).reduce(new SelectOneReducer<Long>()); IterativeDataSet<Long> iteration = mapped.iterate(10); iteration.closeWith( iteration.join(reduced) .where(new IdentityKeyExtractor<Long>()) .equalTo(new IdentityKeyExtractor<Long>()) .with(new DummyFlatJoinFunction<Long>())) .output(new DiscardingOutputFormat<Long>()); compileNoStats(env.createProgramPlan()); } catch(Exception e){ e.printStackTrace(); fail(e.getMessage()); } }
Example #7
Source File: IterationsCompilerTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Test public void testResetPartialSolution() { try { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Long> width = env.generateSequence(1, 10); DataSet<Long> update = env.generateSequence(1, 10); DataSet<Long> lastGradient = env.generateSequence(1, 10); DataSet<Long> init = width.union(update).union(lastGradient); IterativeDataSet<Long> iteration = init.iterate(10); width = iteration.filter(new IdFilter<Long>()); update = iteration.filter(new IdFilter<Long>()); lastGradient = iteration.filter(new IdFilter<Long>()); DataSet<Long> gradient = width.map(new IdentityMapper<Long>()); DataSet<Long> term = gradient.join(lastGradient) .where(new IdentityKeyExtractor<Long>()) .equalTo(new IdentityKeyExtractor<Long>()) .with(new JoinFunction<Long, Long, Long>() { public Long join(Long first, Long second) { return null; } }); update = update.map(new RichMapFunction<Long, Long>() { public Long map(Long value) { return null; } }).withBroadcastSet(term, "some-name"); DataSet<Long> result = iteration.closeWith(width.union(update).union(lastGradient)); result.output(new DiscardingOutputFormat<Long>()); Plan p = env.createProgramPlan(); OptimizedPlan op = compileNoStats(p); new JobGraphGenerator().compileJobGraph(op); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #8
Source File: BranchingPlansCompilerTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Test public void testBranchingBroadcastVariable() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(100); DataSet<String> input1 = env.readTextFile(IN_FILE).name("source1"); DataSet<String> input2 = env.readTextFile(IN_FILE).name("source2"); DataSet<String> input3 = env.readTextFile(IN_FILE).name("source3"); DataSet<String> result1 = input1 .map(new IdentityMapper<String>()) .reduceGroup(new Top1GroupReducer<String>()) .withBroadcastSet(input3, "bc"); DataSet<String> result2 = input2 .map(new IdentityMapper<String>()) .reduceGroup(new Top1GroupReducer<String>()) .withBroadcastSet(input3, "bc"); result1.join(result2) .where(new IdentityKeyExtractor<String>()) .equalTo(new IdentityKeyExtractor<String>()) .with(new RichJoinFunction<String, String, String>() { @Override public String join(String first, String second) { return null; } }) .withBroadcastSet(input3, "bc1") .withBroadcastSet(input1, "bc2") .withBroadcastSet(result1, "bc3") .output(new DiscardingOutputFormat<String>()); Plan plan = env.createProgramPlan(); try{ compileNoStats(plan); }catch(Exception e){ e.printStackTrace(); Assert.fail(e.getMessage()); } }
Example #9
Source File: IterationsCompilerTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testResetPartialSolution() { try { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Long> width = env.generateSequence(1, 10); DataSet<Long> update = env.generateSequence(1, 10); DataSet<Long> lastGradient = env.generateSequence(1, 10); DataSet<Long> init = width.union(update).union(lastGradient); IterativeDataSet<Long> iteration = init.iterate(10); width = iteration.filter(new IdFilter<Long>()); update = iteration.filter(new IdFilter<Long>()); lastGradient = iteration.filter(new IdFilter<Long>()); DataSet<Long> gradient = width.map(new IdentityMapper<Long>()); DataSet<Long> term = gradient.join(lastGradient) .where(new IdentityKeyExtractor<Long>()) .equalTo(new IdentityKeyExtractor<Long>()) .with(new JoinFunction<Long, Long, Long>() { public Long join(Long first, Long second) { return null; } }); update = update.map(new RichMapFunction<Long, Long>() { public Long map(Long value) { return null; } }).withBroadcastSet(term, "some-name"); DataSet<Long> result = iteration.closeWith(width.union(update).union(lastGradient)); result.output(new DiscardingOutputFormat<Long>()); Plan p = env.createProgramPlan(); OptimizedPlan op = compileNoStats(p); new JobGraphGenerator().compileJobGraph(op); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #10
Source File: BranchingPlansCompilerTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testBranchingBroadcastVariable() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(100); DataSet<String> input1 = env.readTextFile(IN_FILE).name("source1"); DataSet<String> input2 = env.readTextFile(IN_FILE).name("source2"); DataSet<String> input3 = env.readTextFile(IN_FILE).name("source3"); DataSet<String> result1 = input1 .map(new IdentityMapper<String>()) .reduceGroup(new Top1GroupReducer<String>()) .withBroadcastSet(input3, "bc"); DataSet<String> result2 = input2 .map(new IdentityMapper<String>()) .reduceGroup(new Top1GroupReducer<String>()) .withBroadcastSet(input3, "bc"); result1.join(result2) .where(new IdentityKeyExtractor<String>()) .equalTo(new IdentityKeyExtractor<String>()) .with(new RichJoinFunction<String, String, String>() { @Override public String join(String first, String second) { return null; } }) .withBroadcastSet(input3, "bc1") .withBroadcastSet(input1, "bc2") .withBroadcastSet(result1, "bc3") .output(new DiscardingOutputFormat<String>()); Plan plan = env.createProgramPlan(); try{ compileNoStats(plan); }catch(Exception e){ e.printStackTrace(); Assert.fail(e.getMessage()); } }
Example #11
Source File: IterationsCompilerTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testResetPartialSolution() { try { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Long> width = env.generateSequence(1, 10); DataSet<Long> update = env.generateSequence(1, 10); DataSet<Long> lastGradient = env.generateSequence(1, 10); DataSet<Long> init = width.union(update).union(lastGradient); IterativeDataSet<Long> iteration = init.iterate(10); width = iteration.filter(new IdFilter<Long>()); update = iteration.filter(new IdFilter<Long>()); lastGradient = iteration.filter(new IdFilter<Long>()); DataSet<Long> gradient = width.map(new IdentityMapper<Long>()); DataSet<Long> term = gradient.join(lastGradient) .where(new IdentityKeyExtractor<Long>()) .equalTo(new IdentityKeyExtractor<Long>()) .with(new JoinFunction<Long, Long, Long>() { public Long join(Long first, Long second) { return null; } }); update = update.map(new RichMapFunction<Long, Long>() { public Long map(Long value) { return null; } }).withBroadcastSet(term, "some-name"); DataSet<Long> result = iteration.closeWith(width.union(update).union(lastGradient)); result.output(new DiscardingOutputFormat<Long>()); Plan p = env.createProgramPlan(); OptimizedPlan op = compileNoStats(p); new JobGraphGenerator().compileJobGraph(op); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #12
Source File: BranchingPlansCompilerTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testBranchingBroadcastVariable() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(100); DataSet<String> input1 = env.readTextFile(IN_FILE).name("source1"); DataSet<String> input2 = env.readTextFile(IN_FILE).name("source2"); DataSet<String> input3 = env.readTextFile(IN_FILE).name("source3"); DataSet<String> result1 = input1 .map(new IdentityMapper<String>()) .reduceGroup(new Top1GroupReducer<String>()) .withBroadcastSet(input3, "bc"); DataSet<String> result2 = input2 .map(new IdentityMapper<String>()) .reduceGroup(new Top1GroupReducer<String>()) .withBroadcastSet(input3, "bc"); result1.join(result2) .where(new IdentityKeyExtractor<String>()) .equalTo(new IdentityKeyExtractor<String>()) .with(new RichJoinFunction<String, String, String>() { @Override public String join(String first, String second) { return null; } }) .withBroadcastSet(input3, "bc1") .withBroadcastSet(input1, "bc2") .withBroadcastSet(result1, "bc3") .output(new DiscardingOutputFormat<String>()); Plan plan = env.createProgramPlan(); try{ compileNoStats(plan); }catch(Exception e){ e.printStackTrace(); Assert.fail(e.getMessage()); } }