Search in sources :

Example 11 with MapOperatorBase

use of org.apache.flink.api.common.operators.base.MapOperatorBase in project flink by apache.

the class SemanticPropertiesPrecedenceTest method testFunctionForwardedAnnotationPrecedence.

@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));
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Plan(org.apache.flink.api.common.Plan) MapOperatorBase(org.apache.flink.api.common.operators.base.MapOperatorBase) FieldSet(org.apache.flink.api.common.operators.util.FieldSet) Tuple3(org.apache.flink.api.java.tuple.Tuple3) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) Test(org.junit.Test)

Example 12 with MapOperatorBase

use of org.apache.flink.api.common.operators.base.MapOperatorBase in project flink by apache.

the class SemanticPropertiesTranslationTest method testUnaryFunctionMovingForwardedAnnotation.

@Test
public void testUnaryFunctionMovingForwardedAnnotation() {
    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 ShufflingMapper<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, 1);
    FieldSet fw3 = semantics.getForwardingTargetFields(0, 2);
    assertNotNull(fw1);
    assertNotNull(fw2);
    assertNotNull(fw3);
    assertTrue(fw1.contains(2));
    assertTrue(fw2.contains(0));
    assertTrue(fw3.contains(1));
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Plan(org.apache.flink.api.common.Plan) MapOperatorBase(org.apache.flink.api.common.operators.base.MapOperatorBase) FieldSet(org.apache.flink.api.common.operators.util.FieldSet) Tuple3(org.apache.flink.api.java.tuple.Tuple3) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) Test(org.junit.Test)

Example 13 with MapOperatorBase

use of org.apache.flink.api.common.operators.base.MapOperatorBase in project flink by apache.

the class SemanticPropertiesTranslationTest method testUnaryFunctionForwardedInLine1.

@Test
public void testUnaryFunctionForwardedInLine1() {
    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 NoAnnotationMapper<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));
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Plan(org.apache.flink.api.common.Plan) MapOperatorBase(org.apache.flink.api.common.operators.base.MapOperatorBase) FieldSet(org.apache.flink.api.common.operators.util.FieldSet) Tuple3(org.apache.flink.api.java.tuple.Tuple3) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) Test(org.junit.Test)

Example 14 with MapOperatorBase

use of org.apache.flink.api.common.operators.base.MapOperatorBase in project flink by apache.

the class SemanticPropertiesTranslationTest method testUnaryFunctionInPlaceForwardedAnnotation.

@Test
public void testUnaryFunctionInPlaceForwardedAnnotation() {
    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 IndividualForwardedMapper<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, 2);
    assertNotNull(fw1);
    assertNotNull(fw2);
    assertTrue(fw1.contains(0));
    assertTrue(fw2.contains(2));
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Plan(org.apache.flink.api.common.Plan) MapOperatorBase(org.apache.flink.api.common.operators.base.MapOperatorBase) FieldSet(org.apache.flink.api.common.operators.util.FieldSet) Tuple3(org.apache.flink.api.java.tuple.Tuple3) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) Test(org.junit.Test)

Example 15 with MapOperatorBase

use of org.apache.flink.api.common.operators.base.MapOperatorBase in project flink by apache.

the class SemanticPropertiesTranslationTest method testUnaryFunctionReadFieldsAnnotation.

@Test
public void testUnaryFunctionReadFieldsAnnotation() {
    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>>()).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 read = semantics.getReadFields(0);
    assertNotNull(read);
    assertEquals(2, read.size());
    assertTrue(read.contains(0));
    assertTrue(read.contains(2));
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Plan(org.apache.flink.api.common.Plan) MapOperatorBase(org.apache.flink.api.common.operators.base.MapOperatorBase) FieldSet(org.apache.flink.api.common.operators.util.FieldSet) Tuple3(org.apache.flink.api.java.tuple.Tuple3) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) Test(org.junit.Test)

Aggregations

MapOperatorBase (org.apache.flink.api.common.operators.base.MapOperatorBase)19 Plan (org.apache.flink.api.common.Plan)16 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)16 Tuple3 (org.apache.flink.api.java.tuple.Tuple3)16 Test (org.junit.Test)16 FieldSet (org.apache.flink.api.common.operators.util.FieldSet)13 SingleInputSemanticProperties (org.apache.flink.api.common.operators.SingleInputSemanticProperties)12 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)3 TupleTypeInfo (org.apache.flink.api.java.typeutils.TupleTypeInfo)3 InvalidProgramException (org.apache.flink.api.common.InvalidProgramException)2 GenericDataSinkBase (org.apache.flink.api.common.operators.GenericDataSinkBase)2 UnaryOperatorInformation (org.apache.flink.api.common.operators.UnaryOperatorInformation)2 DeltaIterationBase (org.apache.flink.api.common.operators.base.DeltaIterationBase)2 GroupReduceOperatorBase (org.apache.flink.api.common.operators.base.GroupReduceOperatorBase)2 InnerJoinOperatorBase (org.apache.flink.api.common.operators.base.InnerJoinOperatorBase)2 MapPartitionOperatorBase (org.apache.flink.api.common.operators.base.MapPartitionOperatorBase)2 ReduceOperatorBase (org.apache.flink.api.common.operators.base.ReduceOperatorBase)2 GroupReduceNode (org.apache.flink.optimizer.dag.GroupReduceNode)2 MapNode (org.apache.flink.optimizer.dag.MapNode)2 MapPartitionNode (org.apache.flink.optimizer.dag.MapPartitionNode)2