Search in sources :

Example 76 with SingleInputSemanticProperties

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

the class GlobalPropertiesFilteringTest method testAnyPartitioningErased.

@Test
public void testAnyPartitioningErased() {
    SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "0;1" }, null, null, tupleInfo, tupleInfo);
    GlobalProperties gprops = new GlobalProperties();
    gprops.setAnyPartitioning(new FieldList(0, 1, 4));
    GlobalProperties result = gprops.filterBySemanticProperties(sprops, 0);
    assertEquals(PartitioningProperty.RANDOM_PARTITIONED, result.getPartitioning());
    assertNull(result.getPartitioningFields());
}
Also used : SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) FieldList(org.apache.flink.api.common.operators.util.FieldList) Test(org.junit.Test)

Example 77 with SingleInputSemanticProperties

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

the class GroupCombineNode method getSemanticPropertiesForLocalPropertyFiltering.

@Override
protected SemanticProperties getSemanticPropertiesForLocalPropertyFiltering() {
    // Local properties for GroupCombine may only be preserved on key fields.
    SingleInputSemanticProperties origProps = ((SingleInputOperator<?, ?, ?>) getOperator()).getSemanticProperties();
    SingleInputSemanticProperties filteredProps = new SingleInputSemanticProperties();
    FieldSet readSet = origProps.getReadFields(0);
    if (readSet != null) {
        filteredProps.addReadFields(readSet);
    }
    // only add forward field information for key fields
    if (this.keys != null) {
        for (int f : this.keys) {
            FieldSet targets = origProps.getForwardingTargetFields(0, f);
            for (int t : targets) {
                filteredProps.addForwardedField(f, t);
            }
        }
    }
    return filteredProps;
}
Also used : FieldSet(org.apache.flink.api.common.operators.util.FieldSet) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) SingleInputOperator(org.apache.flink.api.common.operators.SingleInputOperator)

Example 78 with SingleInputSemanticProperties

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

the class GroupReduceNode method getSemanticPropertiesForLocalPropertyFiltering.

@Override
protected SemanticProperties getSemanticPropertiesForLocalPropertyFiltering() {
    // Local properties for GroupReduce may only be preserved on key fields.
    SingleInputSemanticProperties origProps = getOperator().getSemanticProperties();
    SingleInputSemanticProperties filteredProps = new SingleInputSemanticProperties();
    FieldSet readSet = origProps.getReadFields(0);
    if (readSet != null) {
        filteredProps.addReadFields(readSet);
    }
    // only add forward field information for key fields
    if (this.keys != null) {
        for (int f : this.keys) {
            FieldSet targets = origProps.getForwardingTargetFields(0, f);
            for (int t : targets) {
                filteredProps.addForwardedField(f, t);
            }
        }
    }
    return filteredProps;
}
Also used : FieldSet(org.apache.flink.api.common.operators.util.FieldSet) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties)

Example 79 with SingleInputSemanticProperties

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

the class MapPartitionNode method getSemanticPropertiesForLocalPropertyFiltering.

@Override
protected SemanticProperties getSemanticPropertiesForLocalPropertyFiltering() {
    // Local properties for MapPartition may not be preserved.
    SingleInputSemanticProperties origProps = ((SingleInputOperator<?, ?, ?>) getOperator()).getSemanticProperties();
    SingleInputSemanticProperties filteredProps = new SingleInputSemanticProperties();
    FieldSet readSet = origProps.getReadFields(0);
    if (readSet != null) {
        filteredProps.addReadFields(readSet);
    }
    return filteredProps;
}
Also used : FieldSet(org.apache.flink.api.common.operators.util.FieldSet) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) SingleInputOperator(org.apache.flink.api.common.operators.SingleInputOperator)

Example 80 with SingleInputSemanticProperties

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

the class GlobalPropertiesFilteringTest method testUniqueFieldGroupsPreserved2.

@Test
public void testUniqueFieldGroupsPreserved2() {
    SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "0->5;1;2;3->6;4" }, 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);
    Set<FieldSet> unique = result.getUniqueFieldCombination();
    FieldSet expected1 = new FieldSet(1, 2, 5);
    FieldSet expected2 = new FieldSet(4, 6);
    Assert.assertTrue(unique.size() == 2);
    Assert.assertTrue(unique.contains(expected1));
    Assert.assertTrue(unique.contains(expected2));
}
Also used : FieldSet(org.apache.flink.api.common.operators.util.FieldSet) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) 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