Search in sources :

Example 76 with FieldSet

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

Example 77 with FieldSet

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

the class RequestedLocalPropertiesFilteringTest method testNullProps.

@Test(expected = NullPointerException.class)
public void testNullProps() {
    RequestedLocalProperties rlProp = new RequestedLocalProperties();
    rlProp.setGroupedFields(new FieldSet(0, 2, 3));
    rlProp.filterBySemanticProperties(null, 0);
}
Also used : FieldSet(org.apache.flink.api.common.operators.util.FieldSet) Test(org.junit.Test)

Example 78 with FieldSet

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

the class MapPartitionNodeTest method testGetSemanticProperties.

@Test
public void testGetSemanticProperties() {
    SingleInputSemanticProperties origProps = new SingleInputSemanticProperties();
    origProps.addForwardedField(0, 1);
    origProps.addForwardedField(2, 2);
    origProps.addReadFields(new FieldSet(0, 2, 4, 7));
    MapPartitionOperatorBase<?, ?, ?> op = mock(MapPartitionOperatorBase.class);
    when(op.getSemanticProperties()).thenReturn(origProps);
    when(op.getKeyColumns(0)).thenReturn(new int[] {});
    MapPartitionNode node = new MapPartitionNode(op);
    SemanticProperties filteredProps = node.getSemanticPropertiesForLocalPropertyFiltering();
    assertTrue(filteredProps.getForwardingTargetFields(0, 0).size() == 0);
    assertTrue(filteredProps.getForwardingTargetFields(0, 2).size() == 0);
    assertTrue(filteredProps.getForwardingSourceField(0, 1) < 0);
    assertTrue(filteredProps.getForwardingSourceField(0, 2) < 0);
    assertTrue(filteredProps.getReadFields(0).size() == 4);
    assertTrue(filteredProps.getReadFields(0).contains(0));
    assertTrue(filteredProps.getReadFields(0).contains(2));
    assertTrue(filteredProps.getReadFields(0).contains(4));
    assertTrue(filteredProps.getReadFields(0).contains(7));
}
Also used : SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) SemanticProperties(org.apache.flink.api.common.operators.SemanticProperties) FieldSet(org.apache.flink.api.common.operators.util.FieldSet) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) Test(org.junit.Test)

Example 79 with FieldSet

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

the class LocalPropertiesFilteringTest method testUniqueFieldsErased.

@Test
public void testUniqueFieldsErased() {
    SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[] { "0;1;4" }, null, null, tupleInfo, tupleInfo);
    LocalProperties lProps = new LocalProperties();
    lProps = lProps.addUniqueFields(new FieldSet(0, 1, 2));
    lProps = lProps.addUniqueFields(new FieldSet(3, 4));
    lProps = lProps.addUniqueFields(new FieldSet(4, 5, 6));
    LocalProperties filtered = lProps.filterBySemanticProperties(sp, 0);
    assertNull(filtered.getGroupedFields());
    assertNull(filtered.getOrdering());
    assertNull(filtered.getUniqueFields());
}
Also used : FieldSet(org.apache.flink.api.common.operators.util.FieldSet) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) Test(org.junit.Test)

Example 80 with FieldSet

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

the class LocalPropertiesFilteringTest method testAllErased1.

@Test
public void testAllErased1() {
    SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sp, null, null, null, tupleInfo, tupleInfo);
    LocalProperties lProps = LocalProperties.forGrouping(new FieldList(0, 1, 2));
    lProps = lProps.addUniqueFields(new FieldSet(3, 4));
    lProps = lProps.addUniqueFields(new FieldSet(5, 6));
    LocalProperties filtered = lProps.filterBySemanticProperties(sp, 0);
    assertNull(filtered.getGroupedFields());
    assertNull(filtered.getOrdering());
    assertNull(filtered.getUniqueFields());
}
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