org.apache.flink.api.java.operators.translation.PlanProjectOperator Java Examples
The following examples show how to use
org.apache.flink.api.java.operators.translation.PlanProjectOperator.
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: SemanticPropertiesProjectionTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testProjectionSemProps1() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo); tupleDs.project(1, 3, 2, 0, 3).output(new DiscardingOutputFormat<Tuple>()); Plan plan = env.createProgramPlan(); GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next(); PlanProjectOperator<?, ?> projectOperator = ((PlanProjectOperator<?, ?>) sink.getInput()); SingleInputSemanticProperties props = projectOperator.getSemanticProperties(); assertEquals(1, props.getForwardingTargetFields(0, 0).size()); assertEquals(1, props.getForwardingTargetFields(0, 1).size()); assertEquals(1, props.getForwardingTargetFields(0, 2).size()); assertEquals(2, props.getForwardingTargetFields(0, 3).size()); assertTrue(props.getForwardingTargetFields(0, 1).contains(0)); assertTrue(props.getForwardingTargetFields(0, 3).contains(1)); assertTrue(props.getForwardingTargetFields(0, 2).contains(2)); assertTrue(props.getForwardingTargetFields(0, 0).contains(3)); assertTrue(props.getForwardingTargetFields(0, 3).contains(4)); }
Example #2
Source File: SemanticPropertiesProjectionTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testProjectionSemProps1() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo); tupleDs.project(1, 3, 2, 0, 3).output(new DiscardingOutputFormat<Tuple>()); Plan plan = env.createProgramPlan(); GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next(); PlanProjectOperator<?, ?> projectOperator = ((PlanProjectOperator<?, ?>) sink.getInput()); SingleInputSemanticProperties props = projectOperator.getSemanticProperties(); assertEquals(1, props.getForwardingTargetFields(0, 0).size()); assertEquals(1, props.getForwardingTargetFields(0, 1).size()); assertEquals(1, props.getForwardingTargetFields(0, 2).size()); assertEquals(2, props.getForwardingTargetFields(0, 3).size()); assertTrue(props.getForwardingTargetFields(0, 1).contains(0)); assertTrue(props.getForwardingTargetFields(0, 3).contains(1)); assertTrue(props.getForwardingTargetFields(0, 2).contains(2)); assertTrue(props.getForwardingTargetFields(0, 0).contains(3)); assertTrue(props.getForwardingTargetFields(0, 3).contains(4)); }
Example #3
Source File: SemanticPropertiesProjectionTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testProjectionSemProps1() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo); tupleDs.project(1, 3, 2, 0, 3).output(new DiscardingOutputFormat<Tuple>()); Plan plan = env.createProgramPlan(); GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next(); PlanProjectOperator<?, ?> projectOperator = ((PlanProjectOperator<?, ?>) sink.getInput()); SingleInputSemanticProperties props = projectOperator.getSemanticProperties(); assertEquals(1, props.getForwardingTargetFields(0, 0).size()); assertEquals(1, props.getForwardingTargetFields(0, 1).size()); assertEquals(1, props.getForwardingTargetFields(0, 2).size()); assertEquals(2, props.getForwardingTargetFields(0, 3).size()); assertTrue(props.getForwardingTargetFields(0, 1).contains(0)); assertTrue(props.getForwardingTargetFields(0, 3).contains(1)); assertTrue(props.getForwardingTargetFields(0, 2).contains(2)); assertTrue(props.getForwardingTargetFields(0, 0).contains(3)); assertTrue(props.getForwardingTargetFields(0, 3).contains(4)); }
Example #4
Source File: ProjectOperator.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override protected org.apache.flink.api.common.operators.base.MapOperatorBase<IN, OUT, MapFunction<IN, OUT>> translateToDataFlow(Operator<IN> input) { String name = getName() != null ? getName() : "Projection " + Arrays.toString(fields); // create operator PlanProjectOperator<IN, OUT> ppo = new PlanProjectOperator<IN, OUT>(fields, name, getInputType(), getResultType(), context.getConfig()); // set input ppo.setInput(input); // set parallelism ppo.setParallelism(this.getParallelism()); ppo.setSemanticProperties(SemanticPropUtil.createProjectionPropertiesSingle(fields, (CompositeType<?>) getInputType())); return ppo; }
Example #5
Source File: SemanticPropertiesProjectionTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testProjectionSemProps2() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple4<Integer, Tuple3<String, Integer, Long>, Tuple2<Long, Long>, String>> tupleDs = env.fromCollection(emptyNestedTupleData, nestedTupleTypeInfo); tupleDs.project(2, 3, 1, 2).output(new DiscardingOutputFormat<Tuple>()); Plan plan = env.createProgramPlan(); GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next(); PlanProjectOperator<?, ?> projectOperator = ((PlanProjectOperator<?, ?>) sink.getInput()); SingleInputSemanticProperties props = projectOperator.getSemanticProperties(); assertNotNull(props.getForwardingTargetFields(0, 0)); assertEquals(1, props.getForwardingTargetFields(0, 1).size()); assertEquals(1, props.getForwardingTargetFields(0, 2).size()); assertEquals(1, props.getForwardingTargetFields(0, 3).size()); assertEquals(2, props.getForwardingTargetFields(0, 4).size()); assertEquals(2, props.getForwardingTargetFields(0, 5).size()); assertEquals(1, props.getForwardingTargetFields(0, 6).size()); assertEquals(0, props.getForwardingTargetFields(0, 0).size()); assertTrue(props.getForwardingTargetFields(0, 4).contains(0)); assertTrue(props.getForwardingTargetFields(0, 5).contains(1)); assertTrue(props.getForwardingTargetFields(0, 6).contains(2)); assertTrue(props.getForwardingTargetFields(0, 1).contains(3)); assertTrue(props.getForwardingTargetFields(0, 2).contains(4)); assertTrue(props.getForwardingTargetFields(0, 3).contains(5)); assertTrue(props.getForwardingTargetFields(0, 4).contains(6)); assertTrue(props.getForwardingTargetFields(0, 5).contains(7)); }
Example #6
Source File: ProjectOperator.java From flink with Apache License 2.0 | 5 votes |
@Override protected org.apache.flink.api.common.operators.base.MapOperatorBase<IN, OUT, MapFunction<IN, OUT>> translateToDataFlow(Operator<IN> input) { String name = getName() != null ? getName() : "Projection " + Arrays.toString(fields); // create operator PlanProjectOperator<IN, OUT> ppo = new PlanProjectOperator<IN, OUT>(fields, name, getInputType(), getResultType(), context.getConfig()); // set input ppo.setInput(input); // set parallelism ppo.setParallelism(this.getParallelism()); ppo.setSemanticProperties(SemanticPropUtil.createProjectionPropertiesSingle(fields, (CompositeType<?>) getInputType())); return ppo; }
Example #7
Source File: SemanticPropertiesProjectionTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testProjectionSemProps2() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple4<Integer, Tuple3<String, Integer, Long>, Tuple2<Long, Long>, String>> tupleDs = env.fromCollection(emptyNestedTupleData, nestedTupleTypeInfo); tupleDs.project(2, 3, 1, 2).output(new DiscardingOutputFormat<Tuple>()); Plan plan = env.createProgramPlan(); GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next(); PlanProjectOperator<?, ?> projectOperator = ((PlanProjectOperator<?, ?>) sink.getInput()); SingleInputSemanticProperties props = projectOperator.getSemanticProperties(); assertNotNull(props.getForwardingTargetFields(0, 0)); assertEquals(1, props.getForwardingTargetFields(0, 1).size()); assertEquals(1, props.getForwardingTargetFields(0, 2).size()); assertEquals(1, props.getForwardingTargetFields(0, 3).size()); assertEquals(2, props.getForwardingTargetFields(0, 4).size()); assertEquals(2, props.getForwardingTargetFields(0, 5).size()); assertEquals(1, props.getForwardingTargetFields(0, 6).size()); assertEquals(0, props.getForwardingTargetFields(0, 0).size()); assertTrue(props.getForwardingTargetFields(0, 4).contains(0)); assertTrue(props.getForwardingTargetFields(0, 5).contains(1)); assertTrue(props.getForwardingTargetFields(0, 6).contains(2)); assertTrue(props.getForwardingTargetFields(0, 1).contains(3)); assertTrue(props.getForwardingTargetFields(0, 2).contains(4)); assertTrue(props.getForwardingTargetFields(0, 3).contains(5)); assertTrue(props.getForwardingTargetFields(0, 4).contains(6)); assertTrue(props.getForwardingTargetFields(0, 5).contains(7)); }
Example #8
Source File: ProjectOperator.java From flink with Apache License 2.0 | 5 votes |
@Override protected org.apache.flink.api.common.operators.base.MapOperatorBase<IN, OUT, MapFunction<IN, OUT>> translateToDataFlow(Operator<IN> input) { String name = getName() != null ? getName() : "Projection " + Arrays.toString(fields); // create operator PlanProjectOperator<IN, OUT> ppo = new PlanProjectOperator<IN, OUT>(fields, name, getInputType(), getResultType(), context.getConfig()); // set input ppo.setInput(input); // set parallelism ppo.setParallelism(this.getParallelism()); ppo.setSemanticProperties(SemanticPropUtil.createProjectionPropertiesSingle(fields, (CompositeType<?>) getInputType())); return ppo; }
Example #9
Source File: SemanticPropertiesProjectionTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testProjectionSemProps2() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple4<Integer, Tuple3<String, Integer, Long>, Tuple2<Long, Long>, String>> tupleDs = env.fromCollection(emptyNestedTupleData, nestedTupleTypeInfo); tupleDs.project(2, 3, 1, 2).output(new DiscardingOutputFormat<Tuple>()); Plan plan = env.createProgramPlan(); GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next(); PlanProjectOperator<?, ?> projectOperator = ((PlanProjectOperator<?, ?>) sink.getInput()); SingleInputSemanticProperties props = projectOperator.getSemanticProperties(); assertNotNull(props.getForwardingTargetFields(0, 0)); assertEquals(1, props.getForwardingTargetFields(0, 1).size()); assertEquals(1, props.getForwardingTargetFields(0, 2).size()); assertEquals(1, props.getForwardingTargetFields(0, 3).size()); assertEquals(2, props.getForwardingTargetFields(0, 4).size()); assertEquals(2, props.getForwardingTargetFields(0, 5).size()); assertEquals(1, props.getForwardingTargetFields(0, 6).size()); assertEquals(0, props.getForwardingTargetFields(0, 0).size()); assertTrue(props.getForwardingTargetFields(0, 4).contains(0)); assertTrue(props.getForwardingTargetFields(0, 5).contains(1)); assertTrue(props.getForwardingTargetFields(0, 6).contains(2)); assertTrue(props.getForwardingTargetFields(0, 1).contains(3)); assertTrue(props.getForwardingTargetFields(0, 2).contains(4)); assertTrue(props.getForwardingTargetFields(0, 3).contains(5)); assertTrue(props.getForwardingTargetFields(0, 4).contains(6)); assertTrue(props.getForwardingTargetFields(0, 5).contains(7)); }