Search in sources :

Example 61 with SingleInputSemanticProperties

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

the class SemanticPropUtilTest method testForwardedWithArrowOneString.

@Test
public void testForwardedWithArrowOneString() {
    String[] forwardedFields = { "f0->f0;f1->f2" };
    SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sp, forwardedFields, null, null, threeIntTupleType, fiveIntTupleType);
    assertTrue(sp.getForwardingTargetFields(0, 0).contains(0));
    assertTrue(sp.getForwardingTargetFields(0, 1).contains(2));
    forwardedFields[0] = "0->0;1->2";
    sp = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sp, forwardedFields, null, null, threeIntTupleType, fiveIntTupleType);
    assertTrue(sp.getForwardingTargetFields(0, 0).contains(0));
    assertTrue(sp.getForwardingTargetFields(0, 1).contains(2));
}
Also used : SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) Test(org.junit.Test)

Example 62 with SingleInputSemanticProperties

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

the class SemanticPropertiesTranslationTest method testUnaryFunctionWildcardForwardedAnnotation.

@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));
}
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 63 with SingleInputSemanticProperties

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

the class SemanticPropertiesTranslationTest method testUnaryFunctionAllForwardedExceptAnnotation.

@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));
}
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 64 with SingleInputSemanticProperties

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

the class GlobalPropertiesFilteringTest method testUniqueFieldGroupsErased.

@Test
public void testUniqueFieldGroupsErased() {
    SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "0; 3; 5; 6; 7" }, null, null, tupleInfo, tupleInfo);
    FieldSet set1 = new FieldSet(0, 1, 2);
    FieldSet set2 = new FieldSet(3, 4);
    FieldSet set3 = new FieldSet(4, 5, 6, 7);
    GlobalProperties gprops = new GlobalProperties();
    gprops.addUniqueFieldCombination(set1);
    gprops.addUniqueFieldCombination(set2);
    gprops.addUniqueFieldCombination(set3);
    GlobalProperties result = gprops.filterBySemanticProperties(sprops, 0);
    Assert.assertNull(result.getUniqueFieldCombination());
}
Also used : FieldSet(org.apache.flink.api.common.operators.util.FieldSet) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) Test(org.junit.Test)

Example 65 with SingleInputSemanticProperties

use of org.apache.flink.api.common.operators.SingleInputSemanticProperties 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

SingleInputSemanticProperties (org.apache.flink.api.common.operators.SingleInputSemanticProperties)149 Test (org.junit.Test)131 FieldSet (org.apache.flink.api.common.operators.util.FieldSet)57 FieldList (org.apache.flink.api.common.operators.util.FieldList)26 Ordering (org.apache.flink.api.common.operators.Ordering)15 Plan (org.apache.flink.api.common.Plan)14 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)14 MapOperatorBase (org.apache.flink.api.common.operators.base.MapOperatorBase)12 Tuple3 (org.apache.flink.api.java.tuple.Tuple3)12 DualInputSemanticProperties (org.apache.flink.api.common.operators.DualInputSemanticProperties)5 SemanticProperties (org.apache.flink.api.common.operators.SemanticProperties)5 Internal (org.apache.flink.annotation.Internal)4 SelectorFunctionKeys (org.apache.flink.api.common.operators.Keys.SelectorFunctionKeys)4 InvalidSemanticAnnotationException (org.apache.flink.api.common.operators.SemanticProperties.InvalidSemanticAnnotationException)4 Matcher (java.util.regex.Matcher)3 UnaryOperatorInformation (org.apache.flink.api.common.operators.UnaryOperatorInformation)3 FlatFieldDescriptor (org.apache.flink.api.common.typeutils.CompositeType.FlatFieldDescriptor)3 InvalidFieldReferenceException (org.apache.flink.api.common.typeutils.CompositeType.InvalidFieldReferenceException)3 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)3 Annotation (java.lang.annotation.Annotation)2