本文整理汇总了Java中org.apache.flink.api.java.operators.translation.PlanProjectOperator类的典型用法代码示例。如果您正苦于以下问题:Java PlanProjectOperator类的具体用法?Java PlanProjectOperator怎么用?Java PlanProjectOperator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlanProjectOperator类属于org.apache.flink.api.java.operators.translation包,在下文中一共展示了PlanProjectOperator类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testProjectionSemProps1
import org.apache.flink.api.java.operators.translation.PlanProjectOperator; //导入依赖的package包/类
@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));
}
示例2: translateToDataFlow
import org.apache.flink.api.java.operators.translation.PlanProjectOperator; //导入依赖的package包/类
@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;
}
示例3: testProjectionSemProps2
import org.apache.flink.api.java.operators.translation.PlanProjectOperator; //导入依赖的package包/类
@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));
}
示例4: translateToDataFlow
import org.apache.flink.api.java.operators.translation.PlanProjectOperator; //导入依赖的package包/类
@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());
// set input
ppo.setInput(input);
// set dop
ppo.setDegreeOfParallelism(this.getParallelism());
ppo.setSemanticProperties(SemanticPropUtil.createProjectionPropertiesSingle(fields));
return ppo;
}
示例5: ProjectOperatorTest
import org.apache.flink.api.java.operators.translation.PlanProjectOperator; //导入依赖的package包/类
@Test
public void ProjectOperatorTest() {
try {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);
tupleDs.project(1, 3, 2).types(Long.class, Long.class, String.class).print();
Plan plan = env.createProgramPlan();
GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next();
PlanProjectOperator<?, ?> projectOperator = ((PlanProjectOperator<?, ?>) sink.getInput());
SingleInputSemanticProperties props = projectOperator.getSemanticProperties();
assertTrue(props.getForwardedField(1).size() == 1);
assertTrue(props.getForwardedField(3).size() == 1);
assertTrue(props.getForwardedField(2).size() == 1);
assertTrue(props.getForwardedField(1).contains(0));
assertTrue(props.getForwardedField(3).contains(1));
assertTrue(props.getForwardedField(2).contains(2));
} catch (Exception e) {
System.err.println(e.getMessage());
e.printStackTrace();
fail("Exception in test: " + e.getMessage());
}
}