Search in sources :

Example 66 with FieldList

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

Example 67 with FieldList

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

the class LocalPropertiesFilteringTest method testInvalidInputIndex.

@Test(expected = IndexOutOfBoundsException.class)
public void testInvalidInputIndex() {
    SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "0;1" }, null, null, tupleInfo, tupleInfo);
    LocalProperties lprops = LocalProperties.forGrouping(new FieldList(0, 1));
    lprops.filterBySemanticProperties(sprops, 1);
}
Also used : SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) FieldList(org.apache.flink.api.common.operators.util.FieldList) Test(org.junit.Test)

Example 68 with FieldList

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

the class LocalPropertiesFilteringTest method testUniqueFieldsPreserved2.

@Test
public void testUniqueFieldsPreserved2() {
    SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[] { "0;1;2;3;4" }, null, null, tupleInfo, tupleInfo);
    LocalProperties lProps = LocalProperties.forGrouping(new FieldList(1, 2));
    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);
    FieldSet expected1 = new FieldSet(0, 1, 2);
    FieldSet expected2 = new FieldSet(3, 4);
    assertNull(filtered.getOrdering());
    assertNotNull(filtered.getGroupedFields());
    assertEquals(2, filtered.getGroupedFields().size());
    assertTrue(filtered.getGroupedFields().contains(1));
    assertTrue(filtered.getGroupedFields().contains(2));
    assertNotNull(filtered.getUniqueFields());
    assertEquals(2, filtered.getUniqueFields().size());
    assertTrue(filtered.getUniqueFields().contains(expected1));
    assertTrue(filtered.getUniqueFields().contains(expected2));
}
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)

Example 69 with FieldList

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

the class LocalPropertiesFilteringTest method testSortingPreserved4.

@Test
public void testSortingPreserved4() {
    SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[] { "2->7;5" }, null, null, tupleInfo, tupleInfo);
    Ordering o = new Ordering();
    o.appendOrdering(2, IntValue.class, Order.ASCENDING);
    o.appendOrdering(0, StringValue.class, Order.DESCENDING);
    o.appendOrdering(5, LongValue.class, Order.DESCENDING);
    LocalProperties lProps = LocalProperties.forOrdering(o);
    LocalProperties filtered = lProps.filterBySemanticProperties(sp, 0);
    FieldList gFields = filtered.getGroupedFields();
    Ordering order = filtered.getOrdering();
    assertNotNull(gFields);
    assertEquals(1, gFields.size());
    assertTrue(gFields.contains(7));
    assertNotNull(order);
    assertEquals(1, order.getNumberOfFields());
    assertEquals(7, order.getFieldNumber(0).intValue());
    assertEquals(Order.ASCENDING, order.getOrder(0));
    assertEquals(IntValue.class, order.getType(0));
    assertNull(filtered.getUniqueFields());
}
Also used : Ordering(org.apache.flink.api.common.operators.Ordering) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) FieldList(org.apache.flink.api.common.operators.util.FieldList) Test(org.junit.Test)

Example 70 with FieldList

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

the class GlobalPropertiesFilteringTest method testCustomPartitioningErased.

@Test
public void testCustomPartitioningErased() {
    SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "0;1" }, null, null, tupleInfo, tupleInfo);
    GlobalProperties gprops = new GlobalProperties();
    Partitioner<Tuple2<Long, Integer>> myP = new MockPartitioner();
    gprops.setCustomPartitioned(new FieldList(0, 4), myP);
    GlobalProperties result = gprops.filterBySemanticProperties(sprops, 0);
    assertEquals(PartitioningProperty.RANDOM_PARTITIONED, result.getPartitioning());
    assertNull(result.getPartitioningFields());
    assertNull(result.getCustomPartitioner());
}
Also used : Tuple2(org.apache.flink.api.java.tuple.Tuple2) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) FieldList(org.apache.flink.api.common.operators.util.FieldList) Test(org.junit.Test)

Aggregations

FieldList (org.apache.flink.api.common.operators.util.FieldList)80 Test (org.junit.Test)70 SingleInputPlanNode (org.apache.flink.optimizer.plan.SingleInputPlanNode)31 OptimizedPlan (org.apache.flink.optimizer.plan.OptimizedPlan)28 Plan (org.apache.flink.api.common.Plan)26 SingleInputSemanticProperties (org.apache.flink.api.common.operators.SingleInputSemanticProperties)26 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)25 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)25 Ordering (org.apache.flink.api.common.operators.Ordering)24 SinkPlanNode (org.apache.flink.optimizer.plan.SinkPlanNode)23 DiscardingOutputFormat (org.apache.flink.api.java.io.DiscardingOutputFormat)19 SourcePlanNode (org.apache.flink.optimizer.plan.SourcePlanNode)18 FieldSet (org.apache.flink.api.common.operators.util.FieldSet)14 GlobalProperties (org.apache.flink.optimizer.dataproperties.GlobalProperties)12 DualInputPlanNode (org.apache.flink.optimizer.plan.DualInputPlanNode)12 Channel (org.apache.flink.optimizer.plan.Channel)11 RequestedGlobalProperties (org.apache.flink.optimizer.dataproperties.RequestedGlobalProperties)9 LocalProperties (org.apache.flink.optimizer.dataproperties.LocalProperties)7 PlanNode (org.apache.flink.optimizer.plan.PlanNode)7 Edge (org.apache.flink.graph.Edge)6