Search in sources :

Example 16 with FieldList

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

the class GlobalPropertiesFilteringTest method testRangePartitioningPreserved2.

@Test
public void testRangePartitioningPreserved2() {
    SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "1->3; 2->0; 5->1" }, null, null, tupleInfo, tupleInfo);
    Ordering o = new Ordering();
    o.appendOrdering(1, IntValue.class, Order.ASCENDING);
    o.appendOrdering(5, LongValue.class, Order.DESCENDING);
    o.appendOrdering(2, StringValue.class, Order.ASCENDING);
    GlobalProperties gprops = new GlobalProperties();
    gprops.setRangePartitioned(o);
    GlobalProperties result = gprops.filterBySemanticProperties(sprops, 0);
    assertEquals(PartitioningProperty.RANGE_PARTITIONED, result.getPartitioning());
    FieldList pFields = result.getPartitioningFields();
    assertEquals(3, pFields.size());
    assertEquals(3, pFields.get(0).intValue());
    assertEquals(1, pFields.get(1).intValue());
    assertEquals(0, pFields.get(2).intValue());
    Ordering pOrder = result.getPartitioningOrdering();
    assertEquals(3, pOrder.getNumberOfFields());
    assertEquals(3, pOrder.getFieldNumber(0).intValue());
    assertEquals(1, pOrder.getFieldNumber(1).intValue());
    assertEquals(0, pOrder.getFieldNumber(2).intValue());
    assertEquals(Order.ASCENDING, pOrder.getOrder(0));
    assertEquals(Order.DESCENDING, pOrder.getOrder(1));
    assertEquals(Order.ASCENDING, pOrder.getOrder(2));
    assertEquals(IntValue.class, pOrder.getType(0));
    assertEquals(LongValue.class, pOrder.getType(1));
    assertEquals(StringValue.class, pOrder.getType(2));
}
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 17 with FieldList

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

the class GlobalPropertiesFilteringTest method testHashPartitioningPreserved1.

@Test
public void testHashPartitioningPreserved1() {
    SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "0;1;4" }, null, null, tupleInfo, tupleInfo);
    GlobalProperties gprops = new GlobalProperties();
    gprops.setHashPartitioned(new FieldList(0, 1, 4));
    GlobalProperties result = gprops.filterBySemanticProperties(sprops, 0);
    assertEquals(PartitioningProperty.HASH_PARTITIONED, result.getPartitioning());
    FieldList pFields = result.getPartitioningFields();
    assertEquals(3, pFields.size());
    assertTrue(pFields.contains(0));
    assertTrue(pFields.contains(1));
    assertTrue(pFields.contains(4));
}
Also used : SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) FieldList(org.apache.flink.api.common.operators.util.FieldList) Test(org.junit.Test)

Example 18 with FieldList

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

the class GlobalPropertiesFilteringTest method testCustomPartitioningPreserved2.

@Test
public void testCustomPartitioningPreserved2() {
    SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "0->1; 1->2; 4->3" }, 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.CUSTOM_PARTITIONING, result.getPartitioning());
    FieldList pFields = result.getPartitioningFields();
    assertEquals(2, pFields.size());
    assertTrue(pFields.contains(1));
    assertTrue(pFields.contains(3));
    assertEquals(myP, 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)

Example 19 with FieldList

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

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

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