Search in sources :

Example 1 with FieldSet

use of org.apache.flink.api.common.operators.util.FieldSet in project flink by apache.

the class FieldSetTest method testImmutability.

@Test
public void testImmutability() {
    FieldSet s1 = new FieldSet();
    FieldSet s2 = new FieldSet(5);
    FieldSet s3 = new FieldSet(Integer.valueOf(7));
    FieldSet s4 = new FieldSet(5, 4, 7, 6);
    s1.addFields(s2).addFields(s3);
    s2.addFields(s4);
    s4.addFields(s1);
    s1.addField(Integer.valueOf(14));
    s2.addFields(78, 13, 66, 3);
    assertEquals(0, s1.size());
    assertEquals(1, s2.size());
    assertEquals(1, s3.size());
    assertEquals(4, s4.size());
}
Also used : FieldSet(org.apache.flink.api.common.operators.util.FieldSet) Test(org.junit.Test)

Example 2 with FieldSet

use of org.apache.flink.api.common.operators.util.FieldSet in project flink by apache.

the class FieldSetTest method testFieldSetConstructors.

@Test
public void testFieldSetConstructors() {
    check(new FieldSet());
    check(FieldSet.EMPTY_SET);
    check(new FieldSet(14), 14);
    check(new FieldSet(Integer.valueOf(3)), 3);
    check(new FieldSet(7, 4, 1), 1, 4, 7);
    check(new FieldSet(7, 4, 1, 4, 7, 1, 4, 2), 1, 4, 2, 7);
}
Also used : FieldSet(org.apache.flink.api.common.operators.util.FieldSet) Test(org.junit.Test)

Example 3 with FieldSet

use of org.apache.flink.api.common.operators.util.FieldSet in project flink by apache.

the class SemanticPropertiesPrecedenceTest method testFunctionSkipCodeAnalysisAnnotationPrecedence.

@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));
}
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 4 with FieldSet

use of org.apache.flink.api.common.operators.util.FieldSet in project flink by apache.

the class SemanticPropertiesPrecedenceTest method testFunctionAnalyzerPrecedence.

@Test
public void testFunctionAnalyzerPrecedence() {
    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 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));
}
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 5 with FieldSet

use of org.apache.flink.api.common.operators.util.FieldSet in project flink by apache.

the class GlobalPropertiesFilteringTest method testAllErased2.

@Test
public void testAllErased2() {
    SingleInputSemanticProperties semProps = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(semProps, new String[] { "2" }, null, null, tupleInfo, tupleInfo);
    GlobalProperties gprops = new GlobalProperties();
    gprops.setHashPartitioned(new FieldList(0, 1));
    gprops.addUniqueFieldCombination(new FieldSet(3, 4));
    gprops.addUniqueFieldCombination(new FieldSet(5, 6));
    GlobalProperties result = gprops.filterBySemanticProperties(semProps, 0);
    assertEquals(PartitioningProperty.RANDOM_PARTITIONED, result.getPartitioning());
    assertNull(result.getPartitioningFields());
    assertNull(result.getPartitioningOrdering());
    assertNull(result.getUniqueFieldCombination());
}
Also used : FieldSet(org.apache.flink.api.common.operators.util.FieldSet) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) FieldList(org.apache.flink.api.common.operators.util.FieldList) Test(org.junit.Test)

Aggregations

FieldSet (org.apache.flink.api.common.operators.util.FieldSet)111 Test (org.junit.Test)97 SingleInputSemanticProperties (org.apache.flink.api.common.operators.SingleInputSemanticProperties)57 Plan (org.apache.flink.api.common.Plan)37 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)37 GlobalProperties (org.apache.flink.optimizer.dataproperties.GlobalProperties)28 LocalProperties (org.apache.flink.optimizer.dataproperties.LocalProperties)28 SourcePlanNode (org.apache.flink.optimizer.plan.SourcePlanNode)27 OptimizedPlan (org.apache.flink.optimizer.plan.OptimizedPlan)25 Tuple3 (org.apache.flink.api.java.tuple.Tuple3)24 SinkPlanNode (org.apache.flink.optimizer.plan.SinkPlanNode)24 FieldList (org.apache.flink.api.common.operators.util.FieldList)14 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)14 MapOperatorBase (org.apache.flink.api.common.operators.base.MapOperatorBase)13 DualInputSemanticProperties (org.apache.flink.api.common.operators.DualInputSemanticProperties)9 Ordering (org.apache.flink.api.common.operators.Ordering)9 SemanticProperties (org.apache.flink.api.common.operators.SemanticProperties)5 Channel (org.apache.flink.optimizer.plan.Channel)4 SingleInputPlanNode (org.apache.flink.optimizer.plan.SingleInputPlanNode)4 Configuration (org.apache.flink.configuration.Configuration)3