Search in sources :

Example 21 with FieldList

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

the class LocalPropertiesFilteringTest method testSortingPreserved2.

@Test
public void testSortingPreserved2() {
    SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[] { "0->3;2->7;5->1" }, 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(3, gFields.size());
    assertTrue(gFields.contains(3));
    assertTrue(gFields.contains(7));
    assertTrue(gFields.contains(1));
    assertNotNull(order);
    assertEquals(3, order.getNumberOfFields());
    assertEquals(7, order.getFieldNumber(0).intValue());
    assertEquals(3, order.getFieldNumber(1).intValue());
    assertEquals(1, order.getFieldNumber(2).intValue());
    assertEquals(Order.ASCENDING, order.getOrder(0));
    assertEquals(Order.DESCENDING, order.getOrder(1));
    assertEquals(Order.DESCENDING, order.getOrder(2));
    assertEquals(IntValue.class, order.getType(0));
    assertEquals(StringValue.class, order.getType(1));
    assertEquals(LongValue.class, order.getType(2));
    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 22 with FieldList

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

the class LocalPropertiesFilteringTest method testSortingErased.

@Test
public void testSortingErased() {
    SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[] { "0;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();
    assertNull(gFields);
    assertNull(order);
    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 23 with FieldList

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

the class LocalPropertiesFilteringTest method testAllErased2.

@Test
public void testAllErased2() {
    SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[] { "5" }, null, null, tupleInfo, tupleInfo);
    LocalProperties lProps = LocalProperties.forGrouping(new FieldList(0, 1, 2));
    lProps = lProps.addUniqueFields(new FieldSet(3, 4));
    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 24 with FieldList

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

the class LocalPropertiesFilteringTest method testGroupingPreserved1.

@Test
public void testGroupingPreserved1() {
    SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[] { "0;2;3" }, null, null, tupleInfo, tupleInfo);
    LocalProperties lProps = LocalProperties.forGrouping(new FieldList(0, 2, 3));
    LocalProperties filtered = lProps.filterBySemanticProperties(sp, 0);
    assertNotNull(filtered.getGroupedFields());
    assertEquals(3, filtered.getGroupedFields().size());
    assertTrue(filtered.getGroupedFields().contains(0));
    assertTrue(filtered.getGroupedFields().contains(2));
    assertTrue(filtered.getGroupedFields().contains(3));
    assertNull(filtered.getOrdering());
    assertNull(filtered.getUniqueFields());
}
Also used : SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) FieldList(org.apache.flink.api.common.operators.util.FieldList) Test(org.junit.Test)

Example 25 with FieldList

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

the class LocalPropertiesFilteringTest method testSortingPreserved3.

@Test
public void testSortingPreserved3() {
    SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[] { "0;2" }, 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(2, gFields.size());
    assertTrue(gFields.contains(0));
    assertTrue(gFields.contains(2));
    assertNotNull(order);
    assertEquals(2, order.getNumberOfFields());
    assertEquals(2, order.getFieldNumber(0).intValue());
    assertEquals(0, order.getFieldNumber(1).intValue());
    assertEquals(Order.ASCENDING, order.getOrder(0));
    assertEquals(Order.DESCENDING, order.getOrder(1));
    assertEquals(IntValue.class, order.getType(0));
    assertEquals(StringValue.class, order.getType(1));
    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)

Aggregations

FieldList (org.apache.flink.api.common.operators.util.FieldList)79 Test (org.junit.Test)69 SingleInputPlanNode (org.apache.flink.optimizer.plan.SingleInputPlanNode)30 OptimizedPlan (org.apache.flink.optimizer.plan.OptimizedPlan)27 SingleInputSemanticProperties (org.apache.flink.api.common.operators.SingleInputSemanticProperties)26 Plan (org.apache.flink.api.common.Plan)25 Ordering (org.apache.flink.api.common.operators.Ordering)24 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)24 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)24 SinkPlanNode (org.apache.flink.optimizer.plan.SinkPlanNode)22 DiscardingOutputFormat (org.apache.flink.api.java.io.DiscardingOutputFormat)21 SourcePlanNode (org.apache.flink.optimizer.plan.SourcePlanNode)17 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 DataSet (org.apache.flink.api.java.DataSet)6