org.apache.flink.api.java.io.DiscardingOutputFormat Java Examples
The following examples show how to use
org.apache.flink.api.java.io.DiscardingOutputFormat.
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: SemanticPropertiesTranslationTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testUnaryFunctionWildcardForwardedAnnotation() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); @SuppressWarnings("unchecked") DataSet<Tuple3<Long, String, Integer>> input = env.fromElements(new Tuple3<Long, String, Integer>(3L, "test", 42)); input.map(new WildcardForwardedMapper<Tuple3<Long, String, Integer>>()).output(new DiscardingOutputFormat<Tuple3<Long, String, Integer>>()); Plan plan = env.createProgramPlan(); GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next(); MapOperatorBase<?, ?, ?> mapper = (MapOperatorBase<?, ?, ?>) sink.getInput(); SingleInputSemanticProperties semantics = mapper.getSemanticProperties(); FieldSet fw1 = semantics.getForwardingTargetFields(0, 0); FieldSet fw2 = semantics.getForwardingTargetFields(0, 1); FieldSet fw3 = semantics.getForwardingTargetFields(0, 2); assertNotNull(fw1); assertNotNull(fw2); assertNotNull(fw3); assertTrue(fw1.contains(0)); assertTrue(fw2.contains(1)); assertTrue(fw3.contains(2)); }
Example #2
Source File: ReduceAllTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testReduce() { // construct the plan ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(DEFAULT_PARALLELISM); DataSet<Long> set1 = env.generateSequence(0,1); set1.reduceGroup(new IdentityGroupReducer<Long>()).name("Reduce1") .output(new DiscardingOutputFormat<Long>()).name("Sink"); Plan plan = env.createProgramPlan(); try { OptimizedPlan oPlan = compileNoStats(plan); JobGraphGenerator jobGen = new JobGraphGenerator(); jobGen.compileJobGraph(oPlan); } catch(CompilerException ce) { ce.printStackTrace(); fail("The pact compiler is unable to compile this plan correctly"); } }
Example #3
Source File: HardPlansCompilationTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Source -> Map -> Reduce -> Cross -> Reduce -> Cross -> Reduce -> * |--------------------------/ / * |--------------------------------------------/ * * First cross has SameKeyFirst output contract */ @Test public void testTicket158() { // construct the plan ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(DEFAULT_PARALLELISM); DataSet<Long> set1 = env.generateSequence(0,1); set1.map(new IdentityMapper<Long>()).name("Map1") .groupBy("*").reduceGroup(new IdentityGroupReducer<Long>()).name("Reduce1") .cross(set1).with(new IdentityCrosser<Long>()).withForwardedFieldsFirst("*").name("Cross1") .groupBy("*").reduceGroup(new IdentityGroupReducer<Long>()).name("Reduce2") .cross(set1).with(new IdentityCrosser<Long>()).name("Cross2") .groupBy("*").reduceGroup(new IdentityGroupReducer<Long>()).name("Reduce3") .output(new DiscardingOutputFormat<Long>()).name("Sink"); Plan plan = env.createProgramPlan(); OptimizedPlan oPlan = compileNoStats(plan); JobGraphGenerator jobGen = new JobGraphGenerator(); jobGen.compileJobGraph(oPlan); }
Example #4
Source File: BranchingPlansCompilerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testBranchesOnlyInBCVariables1() { try{ ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(100); DataSet<Long> input = env.generateSequence(1, 10); DataSet<Long> bc_input = env.generateSequence(1, 10); input .map(new IdentityMapper<Long>()).withBroadcastSet(bc_input, "name1") .map(new IdentityMapper<Long>()).withBroadcastSet(bc_input, "name2") .output(new DiscardingOutputFormat<Long>()); Plan plan = env.createProgramPlan(); compileNoStats(plan); } catch(Exception e){ e.printStackTrace(); fail(e.getMessage()); } }
Example #5
Source File: CollectionExecutionAccumulatorsTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testAccumulator() { try { final int numElements = 100; ExecutionEnvironment env = ExecutionEnvironment.createCollectionsEnvironment(); env.generateSequence(1, numElements) .map(new CountingMapper()) .output(new DiscardingOutputFormat<Long>()); JobExecutionResult result = env.execute(); assertTrue(result.getNetRuntime() >= 0); assertEquals(numElements, (int) result.getAccumulatorResult(ACCUMULATOR_NAME)); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #6
Source File: DegreesWithExceptionITCase.java From flink with Apache License 2.0 | 6 votes |
/** * Test inDegrees() with an edge having a trgId that does not exist in the vertex DataSet. */ @Test public void testInDegreesInvalidEdgeTrgId() throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(PARALLELISM); env.getConfig().disableSysoutLogging(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeInvalidTrgData(env), env); try { graph.inDegrees().output(new DiscardingOutputFormat<>()); env.execute(); fail("graph.inDegrees() did not fail."); } catch (Exception e) { // We expect the job to fail with an exception } }
Example #7
Source File: SemanticPropertiesTranslationTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testUnaryFunctionForwardedInLine2() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); @SuppressWarnings("unchecked") DataSet<Tuple3<Long, Long, Long>> input = env.fromElements(new Tuple3<Long, Long, Long>(3L, 2L, 1L)); input.map(new ReadSetMapper<Tuple3<Long, Long, Long>>()).withForwardedFields("0->1; 2") .output(new DiscardingOutputFormat<Tuple3<Long, Long, Long>>()); Plan plan = env.createProgramPlan(); GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next(); MapOperatorBase<?, ?, ?> mapper = (MapOperatorBase<?, ?, ?>) sink.getInput(); SingleInputSemanticProperties semantics = mapper.getSemanticProperties(); FieldSet fw1 = semantics.getForwardingTargetFields(0, 0); FieldSet fw2 = semantics.getForwardingTargetFields(0, 2); assertNotNull(fw1); assertNotNull(fw2); assertTrue(fw1.contains(1)); assertTrue(fw2.contains(2)); }
Example #8
Source File: CustomInputSplitProgram.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.getConfig().disableSysoutLogging(); DataSet<Integer> data = env.createInput(new CustomInputFormat()); data .map(new MapFunction<Integer, Tuple2<Integer, Double>>() { @Override public Tuple2<Integer, Double> map(Integer value) { return new Tuple2<Integer, Double>(value, value * 0.5); } }) .output(new DiscardingOutputFormat<Tuple2<Integer, Double>>()); env.execute(); }
Example #9
Source File: SemanticPropertiesTranslationTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testUnaryFunctionAllForwardedExceptAnnotation() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); @SuppressWarnings("unchecked") DataSet<Tuple3<Long, Long, Long>> input = env.fromElements(new Tuple3<Long, Long, Long>(3L, 2L, 1L)); input.map(new AllForwardedExceptMapper<Tuple3<Long, Long, Long>>()).output(new DiscardingOutputFormat<Tuple3<Long, Long, Long>>()); Plan plan = env.createProgramPlan(); GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next(); MapOperatorBase<?, ?, ?> mapper = (MapOperatorBase<?, ?, ?>) sink.getInput(); SingleInputSemanticProperties semantics = mapper.getSemanticProperties(); FieldSet fw1 = semantics.getForwardingTargetFields(0, 0); FieldSet fw2 = semantics.getForwardingTargetFields(0, 2); assertNotNull(fw1); assertNotNull(fw2); assertTrue(fw1.contains(0)); assertTrue(fw2.contains(2)); }
Example #10
Source File: AccumulatorErrorITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testInvalidTypeAccumulator() throws Exception { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.getConfig().disableSysoutLogging(); // Test Exception forwarding with faulty Accumulator implementation env.generateSequence(0, 10000) .map(new IncompatibleAccumulatorTypesMapper()) .map(new IncompatibleAccumulatorTypesMapper2()) .output(new DiscardingOutputFormat<>()); try { env.execute(); fail("Should have failed."); } catch (JobExecutionException e) { assertTrue("Root cause should be:", e.getCause() instanceof Exception); assertTrue("Root cause should be:", e.getCause().getCause() instanceof UnsupportedOperationException); } }
Example #11
Source File: DisjointDataFlowsTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testDisjointFlows() { try { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); // generate two different flows env.generateSequence(1, 10) .output(new DiscardingOutputFormat<Long>()); env.generateSequence(1, 10) .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: JoinCancelingITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testCancelSortMatchWhileDoingHeavySorting() throws Exception { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); HeavyCompareGeneratorInputFormat input = new HeavyCompareGeneratorInputFormat(100); DataSet<Tuple2<HeavyCompare, Integer>> input1 = env.createInput(input); DataSet<Tuple2<HeavyCompare, Integer>> input2 = env.createInput(input); input1.join(input2, JoinOperatorBase.JoinHint.REPARTITION_SORT_MERGE) .where(0) .equalTo(0) .with(new JoinFunction<Tuple2<HeavyCompare, Integer>, Tuple2<HeavyCompare, Integer>, Tuple2<HeavyCompare, Integer>>() { @Override public Tuple2<HeavyCompare, Integer> join( Tuple2<HeavyCompare, Integer> first, Tuple2<HeavyCompare, Integer> second) throws Exception { throw new Exception("Job should be canceled in sort-merge phase, never run here ..."); } }) .output(new DiscardingOutputFormat<Tuple2<HeavyCompare, Integer>>()); runAndCancelJob(env.createProgramPlan(), 30 * 1000, 60 * 1000); }
Example #13
Source File: IterationCompilerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testIdentityIteration() { try { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(43); IterativeDataSet<Long> iteration = env.generateSequence(-4, 1000).iterate(100); iteration.closeWith(iteration).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 #14
Source File: DegreesWithExceptionITCase.java From flink with Apache License 2.0 | 6 votes |
/** * Test outDegrees() with an edge having a srcId that does not exist in the vertex DataSet. */ @Test public void testOutDegreesInvalidEdgeSrcId() throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(PARALLELISM); env.getConfig().disableSysoutLogging(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeInvalidSrcData(env), env); try { graph.outDegrees().output(new DiscardingOutputFormat<>()); env.execute(); fail("graph.outDegrees() did not fail."); } catch (Exception e) { // We expect the job to fail with an exception } }
Example #15
Source File: DegreesWithExceptionITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Test outDegrees() with an edge having a srcId that does not exist in the vertex DataSet. */ @Test public void testOutDegreesInvalidEdgeSrcId() throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(PARALLELISM); env.getConfig().disableSysoutLogging(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeInvalidSrcData(env), env); try { graph.outDegrees().output(new DiscardingOutputFormat<>()); env.execute(); fail("graph.outDegrees() did not fail."); } catch (Exception e) { // We expect the job to fail with an exception } }
Example #16
Source File: ReduceOnNeighborsWithExceptionITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Test groupReduceOnNeighbors() -NeighborsFunctionWithVertexValue- * with an edge having a trgId that does not exist in the vertex DataSet. */ @Test public void testGroupReduceOnNeighborsWithVVInvalidEdgeTrgId() throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(PARALLELISM); env.getConfig().disableSysoutLogging(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeInvalidTrgData(env), env); try { DataSet<Tuple2<Long, Long>> verticesWithSumOfOutNeighborValues = graph.groupReduceOnNeighbors(new SumAllNeighbors(), EdgeDirection.ALL); verticesWithSumOfOutNeighborValues.output(new DiscardingOutputFormat<>()); env.execute(); fail("Expected an exception."); } catch (Exception e) { // We expect the job to fail with an exception } }
Example #17
Source File: JoinCancelingITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private void executeTaskWithGenerator( JoinFunction<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> joiner, int keys, int vals, int msecsTillCanceling, int maxTimeTillCanceled) throws Exception { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple2<Integer, Integer>> input1 = env.createInput(new UniformIntTupleGeneratorInputFormat(keys, vals)); DataSet<Tuple2<Integer, Integer>> input2 = env.createInput(new UniformIntTupleGeneratorInputFormat(keys, vals)); input1.join(input2, JoinOperatorBase.JoinHint.REPARTITION_SORT_MERGE) .where(0) .equalTo(0) .with(joiner) .output(new DiscardingOutputFormat<Tuple2<Integer, Integer>>()); env.setParallelism(PARALLELISM); runAndCancelJob(env.createProgramPlan(), msecsTillCanceling, maxTimeTillCanceled); }
Example #18
Source File: ReduceOnNeighborsWithExceptionITCase.java From flink with Apache License 2.0 | 6 votes |
/** * Test groupReduceOnNeighbors() -NeighborsFunctionWithVertexValue- * with an edge having a srcId that does not exist in the vertex DataSet. */ @Test public void testGroupReduceOnNeighborsWithVVInvalidEdgeSrcId() throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(PARALLELISM); env.getConfig().disableSysoutLogging(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeInvalidSrcData(env), env); try { DataSet<Tuple2<Long, Long>> verticesWithSumOfOutNeighborValues = graph.groupReduceOnNeighbors(new SumAllNeighbors(), EdgeDirection.ALL); verticesWithSumOfOutNeighborValues.output(new DiscardingOutputFormat<>()); env.execute(); fail("Expected an exception."); } catch (Exception e) { // We expect the job to fail with an exception } }
Example #19
Source File: GroupingTupleTranslationTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testCustomPartitioningTupleAgg() { try { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple2<Integer, Integer>> data = env.fromElements(new Tuple2<Integer, Integer>(0, 0)) .rebalance().setParallelism(4); data.groupBy(0).withPartitioner(new TestPartitionerInt()) .sum(1) .output(new DiscardingOutputFormat<Tuple2<Integer, Integer>>()); Plan p = env.createProgramPlan(); OptimizedPlan op = compileNoStats(p); SinkPlanNode sink = op.getDataSinks().iterator().next(); SingleInputPlanNode reducer = (SingleInputPlanNode) sink.getInput().getSource(); SingleInputPlanNode combiner = (SingleInputPlanNode) reducer.getInput().getSource(); assertEquals(ShipStrategyType.FORWARD, sink.getInput().getShipStrategy()); assertEquals(ShipStrategyType.PARTITION_CUSTOM, reducer.getInput().getShipStrategy()); assertEquals(ShipStrategyType.FORWARD, combiner.getInput().getShipStrategy()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #20
Source File: HypercubeGraphTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testParallelism() throws Exception { int parallelism = 2; Graph<LongValue, NullValue, NullValue> graph = new HypercubeGraph(env, 4) .setParallelism(parallelism) .generate(); graph.getVertices().output(new DiscardingOutputFormat<>()); graph.getEdges().output(new DiscardingOutputFormat<>()); TestUtils.verifyParallelism(env, parallelism); }
Example #21
Source File: DistinctAndGroupingOptimizerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testDistinctDestroysPartitioningOfNonDistinctFields() { try { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(4); @SuppressWarnings("unchecked") DataSet<Tuple2<Long, Long>> data = env.fromElements(new Tuple2<Long, Long>(0L, 0L), new Tuple2<Long, Long>(1L, 1L)) .map(new IdentityMapper<Tuple2<Long,Long>>()).setParallelism(4); data.distinct(1) .groupBy(0) .sum(1) .output(new DiscardingOutputFormat<Tuple2<Long, Long>>()); Plan p = env.createProgramPlan(); OptimizedPlan op = compileNoStats(p); SinkPlanNode sink = op.getDataSinks().iterator().next(); SingleInputPlanNode reducer = (SingleInputPlanNode) sink.getInput().getSource(); SingleInputPlanNode combiner = (SingleInputPlanNode) reducer.getInput().getSource(); SingleInputPlanNode distinctReducer = (SingleInputPlanNode) combiner.getInput().getSource(); assertEquals(ShipStrategyType.FORWARD, sink.getInput().getShipStrategy()); // reducer must repartition, because it works on a different field assertEquals(ShipStrategyType.PARTITION_HASH, reducer.getInput().getShipStrategy()); assertEquals(ShipStrategyType.FORWARD, combiner.getInput().getShipStrategy()); // distinct reducer is partitioned assertEquals(ShipStrategyType.PARTITION_HASH, distinctReducer.getInput().getShipStrategy()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #22
Source File: EchoGraphTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testParallelism() throws Exception { int parallelism = 2; Graph<LongValue, NullValue, NullValue> graph = new EchoGraph(env, 10, 3) .setParallelism(parallelism) .generate(); graph.getVertices().output(new DiscardingOutputFormat<>()); graph.getEdges().output(new DiscardingOutputFormat<>()); TestUtils.verifyParallelism(env, parallelism); }
Example #23
Source File: SuccessAfterNetworkBuffersFailureITCase.java From flink with Apache License 2.0 | 5 votes |
private static void runConnectedComponents(ExecutionEnvironment env) throws Exception { env.setParallelism(PARALLELISM); env.getConfig().disableSysoutLogging(); // read vertex and edge data DataSet<Long> vertices = ConnectedComponentsData.getDefaultVertexDataSet(env) .rebalance(); DataSet<Tuple2<Long, Long>> edges = ConnectedComponentsData.getDefaultEdgeDataSet(env) .rebalance() .flatMap(new ConnectedComponents.UndirectEdge()); // assign the initial components (equal to the vertex id) DataSet<Tuple2<Long, Long>> verticesWithInitialId = vertices .map(new ConnectedComponents.DuplicateValue<Long>()); // open a delta iteration DeltaIteration<Tuple2<Long, Long>, Tuple2<Long, Long>> iteration = verticesWithInitialId.iterateDelta(verticesWithInitialId, 100, 0); // apply the step logic: join with the edges, select the minimum neighbor, // update if the component of the candidate is smaller DataSet<Tuple2<Long, Long>> changes = iteration.getWorkset().join(edges) .where(0).equalTo(0) .with(new ConnectedComponents.NeighborWithComponentIDJoin()) .groupBy(0).aggregate(Aggregations.MIN, 1) .join(iteration.getSolutionSet()) .where(0).equalTo(0) .with(new ConnectedComponents.ComponentIdFilter()); // close the delta iteration (delta and new workset are identical) DataSet<Tuple2<Long, Long>> result = iteration.closeWith(changes, changes); result.output(new DiscardingOutputFormat<Tuple2<Long, Long>>()); env.execute(); }
Example #24
Source File: DistinctTranslationTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void translateDistinctExpressionKey() { try { final int parallelism = 8; ExecutionEnvironment env = ExecutionEnvironment.createLocalEnvironment(parallelism); DataSet<CustomType> initialData = getSourcePojoDataSet(env); initialData.distinct("myInt").output(new DiscardingOutputFormat<CustomType>()); Plan p = env.createProgramPlan(); GenericDataSinkBase<?> sink = p.getDataSinks().iterator().next(); // currently distinct is translated to a Reduce ReduceOperatorBase<?, ?> reducer = (ReduceOperatorBase<?, ?>) sink.getInput(); // check types assertEquals(initialData.getType(), reducer.getOperatorInfo().getInputType()); assertEquals(initialData.getType(), reducer.getOperatorInfo().getOutputType()); // check keys assertArrayEquals(new int[] {0}, reducer.getKeyColumns(0)); // parallelism was not configured on the operator assertTrue(reducer.getParallelism() == 1 || reducer.getParallelism() == -1); assertTrue(reducer.getInput() instanceof GenericDataSourceBase<?, ?>); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); fail("Test caused an error: " + e.getMessage()); } }
Example #25
Source File: SemanticPropertiesPrecedenceTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testFunctionSkipCodeAnalysisAnnotationPrecedence() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.getConfig().setCodeAnalysisMode(CodeAnalysisMode.OPTIMIZE); @SuppressWarnings("unchecked") DataSet<Tuple3<Long, String, Integer>> input = env.fromElements(Tuple3.of(3L, "test", 42)); input .map(new WildcardForwardedMapperWithSkipAnnotation<Tuple3<Long, String, Integer>>()) .output(new DiscardingOutputFormat<Tuple3<Long, String, Integer>>()); Plan plan = env.createProgramPlan(); GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next(); MapOperatorBase<?, ?, ?> mapper = (MapOperatorBase<?, ?, ?>) sink.getInput(); SingleInputSemanticProperties semantics = mapper.getSemanticProperties(); FieldSet fw1 = semantics.getForwardingTargetFields(0, 0); FieldSet fw2 = semantics.getForwardingTargetFields(0, 1); FieldSet fw3 = semantics.getForwardingTargetFields(0, 2); assertNotNull(fw1); assertNotNull(fw2); assertNotNull(fw3); assertFalse(fw1.contains(0)); assertFalse(fw2.contains(1)); assertFalse(fw3.contains(2)); }
Example #26
Source File: SemanticPropertiesPrecedenceTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testFunctionForwardedAnnotationPrecedence() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.getConfig().setCodeAnalysisMode(CodeAnalysisMode.OPTIMIZE); @SuppressWarnings("unchecked") DataSet<Tuple3<Long, String, Integer>> input = env.fromElements(Tuple3.of(3L, "test", 42)); input .map(new WildcardForwardedMapperWithForwardAnnotation<Tuple3<Long, String, Integer>>()) .output(new DiscardingOutputFormat<Tuple3<Long, String, Integer>>()); Plan plan = env.createProgramPlan(); GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next(); MapOperatorBase<?, ?, ?> mapper = (MapOperatorBase<?, ?, ?>) sink.getInput(); SingleInputSemanticProperties semantics = mapper.getSemanticProperties(); FieldSet fw1 = semantics.getForwardingTargetFields(0, 0); FieldSet fw2 = semantics.getForwardingTargetFields(0, 1); FieldSet fw3 = semantics.getForwardingTargetFields(0, 2); assertNotNull(fw1); assertNotNull(fw2); assertNotNull(fw3); assertTrue(fw1.contains(0)); assertFalse(fw2.contains(1)); assertFalse(fw3.contains(2)); }
Example #27
Source File: CustomPartitioningITCase.java From flink with Apache License 2.0 | 5 votes |
@Override protected void testProgram() throws Exception { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); if (!isCollectionExecution()) { Assert.assertTrue(env.getParallelism() > 1); } env.generateSequence(1, 1000) .partitionCustom(new AllZeroPartitioner(), new IdKeySelector<Long>()) .map(new FailExceptInPartitionZeroMapper()) .output(new DiscardingOutputFormat<Long>()); env.execute(); }
Example #28
Source File: ExecutionPlanAfterExecutionTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testGetExecutionPlanOfRangePartition() { ExecutionEnvironment env = new LocalEnvironment(); env.getConfig().disableSysoutLogging(); DataSet<Integer> baseSet = env.fromElements(1, 2); DataSet<Tuple2<Integer, Integer>> result = baseSet .map(new MapFunction<Integer, Tuple2<Integer, Integer>>() { @Override public Tuple2<Integer, Integer> map(Integer value) throws Exception { return new Tuple2(value, value * 2); } }) .partitionByRange(0) .aggregate(Aggregations.MAX, 1); result.output(new DiscardingOutputFormat<Tuple2<Integer, Integer>>()); try { env.getExecutionPlan(); env.execute(); } catch (Exception e) { e.printStackTrace(); fail("Cannot run both #getExecutionPlan and #execute."); } }
Example #29
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 #30
Source File: JobGraphGeneratorTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testGeneratingJobGraphWithUnconsumedResultPartition() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple2<Long, Long>> input = env.fromElements(new Tuple2<>(1L, 2L)) .setParallelism(1); DataSet<Tuple2<Long, Long>> ds = input.map(new IdentityMapper<>()) .setParallelism(3); AbstractID intermediateDataSetID = new AbstractID(); // this output branch will be excluded. ds.output(BlockingShuffleOutputFormat.createOutputFormat(intermediateDataSetID)) .setParallelism(1); // this is the normal output branch. ds.output(new DiscardingOutputFormat<>()) .setParallelism(1); JobGraph jobGraph = compileJob(env); Assert.assertEquals(3, jobGraph.getVerticesSortedTopologicallyFromSources().size()); JobVertex mapVertex = jobGraph.getVerticesSortedTopologicallyFromSources().get(1); Assert.assertThat(mapVertex, Matchers.instanceOf(JobVertex.class)); // there are 2 output result with one of them is ResultPartitionType.BLOCKING_PERSISTENT Assert.assertEquals(2, mapVertex.getProducedDataSets().size()); Assert.assertTrue(mapVertex.getProducedDataSets().stream() .anyMatch(dataSet -> dataSet.getId().equals(new IntermediateDataSetID(intermediateDataSetID)) && dataSet.getResultType() == ResultPartitionType.BLOCKING_PERSISTENT)); }