Search in sources :

Example 6 with Ordering

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

the class GlobalPropertiesMatchingTest method testStrictlyMatchingHashPartitioning.

@Test
public void testStrictlyMatchingHashPartitioning() {
    RequestedGlobalProperties req = new RequestedGlobalProperties();
    req.setHashPartitioned(new FieldList(6, 2));
    // match any partitioning
    {
        GlobalProperties gp1 = new GlobalProperties();
        gp1.setAnyPartitioning(new FieldList(6, 2));
        assertFalse(req.isMetBy(gp1));
        GlobalProperties gp2 = new GlobalProperties();
        gp2.setAnyPartitioning(new FieldList(2, 6));
        assertFalse(req.isMetBy(gp2));
        GlobalProperties gp3 = new GlobalProperties();
        gp3.setAnyPartitioning(new FieldList(6, 1));
        assertFalse(req.isMetBy(gp3));
        GlobalProperties gp4 = new GlobalProperties();
        gp4.setAnyPartitioning(new FieldList(2));
        assertFalse(req.isMetBy(gp4));
    }
    // match hash partitioning
    {
        GlobalProperties gp1 = new GlobalProperties();
        gp1.setHashPartitioned(new FieldList(6, 2));
        assertTrue(req.isMetBy(gp1));
        GlobalProperties gp2 = new GlobalProperties();
        gp2.setHashPartitioned(new FieldList(2, 6));
        assertFalse(req.isMetBy(gp2));
        GlobalProperties gp3 = new GlobalProperties();
        gp3.setHashPartitioned(new FieldList(6, 1));
        assertFalse(req.isMetBy(gp3));
        GlobalProperties gp4 = new GlobalProperties();
        gp4.setHashPartitioned(new FieldList(6, 2, 0));
        assertFalse(req.isMetBy(gp4));
    }
    // match range partitioning
    {
        GlobalProperties gp1 = new GlobalProperties();
        gp1.setRangePartitioned(new Ordering(6, null, Order.DESCENDING).appendOrdering(2, null, Order.ASCENDING));
        assertFalse(req.isMetBy(gp1));
        GlobalProperties gp2 = new GlobalProperties();
        gp2.setRangePartitioned(new Ordering(2, null, Order.DESCENDING).appendOrdering(6, null, Order.ASCENDING));
        assertFalse(req.isMetBy(gp2));
        GlobalProperties gp3 = new GlobalProperties();
        gp3.setRangePartitioned(new Ordering(6, null, Order.DESCENDING).appendOrdering(1, null, Order.ASCENDING));
        assertFalse(req.isMetBy(gp3));
        GlobalProperties gp4 = new GlobalProperties();
        gp4.setRangePartitioned(new Ordering(6, null, Order.DESCENDING));
        assertFalse(req.isMetBy(gp4));
    }
}
Also used : Ordering(org.apache.flink.api.common.operators.Ordering) FieldList(org.apache.flink.api.common.operators.util.FieldList) Test(org.junit.Test)

Example 7 with Ordering

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

the class GlobalPropertiesMatchingTest method testStrictlyMatchingAnyPartitioning.

@Test
public void testStrictlyMatchingAnyPartitioning() {
    RequestedGlobalProperties req = new RequestedGlobalProperties();
    req.setAnyPartitioning(new FieldList(6, 2));
    // match any partitioning
    {
        GlobalProperties gp1 = new GlobalProperties();
        gp1.setAnyPartitioning(new FieldList(6, 2));
        assertTrue(req.isMetBy(gp1));
        GlobalProperties gp2 = new GlobalProperties();
        gp2.setAnyPartitioning(new FieldList(2, 6));
        assertFalse(req.isMetBy(gp2));
        GlobalProperties gp3 = new GlobalProperties();
        gp3.setAnyPartitioning(new FieldList(6, 2, 3));
        assertFalse(req.isMetBy(gp3));
        GlobalProperties gp4 = new GlobalProperties();
        gp4.setAnyPartitioning(new FieldList(6, 1));
        assertFalse(req.isMetBy(gp4));
        GlobalProperties gp5 = new GlobalProperties();
        gp5.setAnyPartitioning(new FieldList(2));
        assertFalse(req.isMetBy(gp5));
    }
    // match hash partitioning
    {
        GlobalProperties gp1 = new GlobalProperties();
        gp1.setHashPartitioned(new FieldList(6, 2));
        assertTrue(req.isMetBy(gp1));
        GlobalProperties gp2 = new GlobalProperties();
        gp2.setHashPartitioned(new FieldList(2, 6));
        assertFalse(req.isMetBy(gp2));
        GlobalProperties gp3 = new GlobalProperties();
        gp3.setHashPartitioned(new FieldList(6, 1));
        assertFalse(req.isMetBy(gp3));
    }
    // match range partitioning
    {
        GlobalProperties gp1 = new GlobalProperties();
        gp1.setRangePartitioned(new Ordering(6, null, Order.DESCENDING).appendOrdering(2, null, Order.ASCENDING));
        assertTrue(req.isMetBy(gp1));
        GlobalProperties gp2 = new GlobalProperties();
        gp2.setRangePartitioned(new Ordering(2, null, Order.DESCENDING).appendOrdering(6, null, Order.ASCENDING));
        assertFalse(req.isMetBy(gp2));
        GlobalProperties gp3 = new GlobalProperties();
        gp3.setRangePartitioned(new Ordering(6, null, Order.DESCENDING).appendOrdering(1, null, Order.ASCENDING));
        assertFalse(req.isMetBy(gp3));
        GlobalProperties gp4 = new GlobalProperties();
        gp4.setRangePartitioned(new Ordering(6, null, Order.DESCENDING));
        assertFalse(req.isMetBy(gp4));
    }
}
Also used : Ordering(org.apache.flink.api.common.operators.Ordering) FieldList(org.apache.flink.api.common.operators.util.FieldList) Test(org.junit.Test)

Example 8 with Ordering

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

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

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

Ordering (org.apache.flink.api.common.operators.Ordering)52 Test (org.junit.Test)28 FieldList (org.apache.flink.api.common.operators.util.FieldList)24 SingleInputSemanticProperties (org.apache.flink.api.common.operators.SingleInputSemanticProperties)15 FieldSet (org.apache.flink.api.common.operators.util.FieldSet)9 GlobalProperties (org.apache.flink.optimizer.dataproperties.GlobalProperties)9 RequestedGlobalProperties (org.apache.flink.optimizer.dataproperties.RequestedGlobalProperties)9 LocalProperties (org.apache.flink.optimizer.dataproperties.LocalProperties)6 Channel (org.apache.flink.optimizer.plan.Channel)6 SingleInputPlanNode (org.apache.flink.optimizer.plan.SingleInputPlanNode)6 UnaryOperatorInformation (org.apache.flink.api.common.operators.UnaryOperatorInformation)5 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)5 RequestedLocalProperties (org.apache.flink.optimizer.dataproperties.RequestedLocalProperties)5 Partitioner (org.apache.flink.api.common.functions.Partitioner)4 Keys (org.apache.flink.api.common.operators.Keys)4 SelectorFunctionKeys (org.apache.flink.api.common.operators.Keys.SelectorFunctionKeys)4 CompilerException (org.apache.flink.optimizer.CompilerException)4 FeedbackPropertiesMeetRequirementsReport (org.apache.flink.optimizer.plan.PlanNode.FeedbackPropertiesMeetRequirementsReport)4 SourcePlanNode (org.apache.flink.optimizer.plan.SourcePlanNode)4 InvalidProgramException (org.apache.flink.api.common.InvalidProgramException)3