Search in sources :

Example 61 with FieldList

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

the class GlobalPropertiesFilteringTest method testHashPartitioningPreserved2.

@Test
public void testHashPartitioningPreserved2() {
    SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "0->1; 1->2; 4->3" }, 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(1));
    assertTrue(pFields.contains(2));
    assertTrue(pFields.contains(3));
}
Also used : SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) FieldList(org.apache.flink.api.common.operators.util.FieldList) Test(org.junit.Test)

Example 62 with FieldList

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

the class GlobalPropertiesMatchingTest method testMatchingCustomPartitioning.

@Test
public void testMatchingCustomPartitioning() {
    try {
        final Partitioner<Tuple2<Long, Integer>> partitioner = new MockPartitioner();
        RequestedGlobalProperties req = new RequestedGlobalProperties();
        req.setCustomPartitioned(new FieldSet(6, 2), partitioner);
        // match custom partitionings
        {
            GlobalProperties gp1 = new GlobalProperties();
            gp1.setCustomPartitioned(new FieldList(2, 6), partitioner);
            assertTrue(req.isMetBy(gp1));
            GlobalProperties gp2 = new GlobalProperties();
            gp2.setCustomPartitioned(new FieldList(6, 2), partitioner);
            assertTrue(req.isMetBy(gp2));
            GlobalProperties gp3 = new GlobalProperties();
            gp3.setCustomPartitioned(new FieldList(6, 2), new MockPartitioner());
            assertFalse(req.isMetBy(gp3));
        }
        // cannot match other types of partitionings
        {
            GlobalProperties gp1 = new GlobalProperties();
            gp1.setAnyPartitioning(new FieldList(6, 2));
            assertFalse(req.isMetBy(gp1));
            GlobalProperties gp2 = new GlobalProperties();
            gp2.setHashPartitioned(new FieldList(6, 2));
            assertFalse(req.isMetBy(gp2));
            GlobalProperties gp3 = new GlobalProperties();
            gp3.setRangePartitioned(new Ordering(2, null, Order.DESCENDING).appendOrdering(6, null, Order.ASCENDING));
            assertFalse(req.isMetBy(gp3));
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : FieldSet(org.apache.flink.api.common.operators.util.FieldSet) Tuple2(org.apache.flink.api.java.tuple.Tuple2) Ordering(org.apache.flink.api.common.operators.Ordering) FieldList(org.apache.flink.api.common.operators.util.FieldList) Test(org.junit.Test)

Example 63 with FieldList

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

the class GlobalPropertiesMatchingTest method testMatchingAnyPartitioning.

@Test
public void testMatchingAnyPartitioning() {
    try {
        RequestedGlobalProperties req = new RequestedGlobalProperties();
        req.setAnyPartitioning(new FieldSet(6, 2));
        // match any partitioning
        {
            GlobalProperties gp1 = new GlobalProperties();
            gp1.setAnyPartitioning(new FieldList(2, 6));
            assertTrue(req.isMetBy(gp1));
            GlobalProperties gp2 = new GlobalProperties();
            gp2.setAnyPartitioning(new FieldList(6, 2));
            assertTrue(req.isMetBy(gp2));
            GlobalProperties gp3 = new GlobalProperties();
            gp3.setAnyPartitioning(new FieldList(6, 2, 4));
            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));
            assertTrue(req.isMetBy(gp5));
        }
        // match hash partitioning
        {
            GlobalProperties gp1 = new GlobalProperties();
            gp1.setHashPartitioned(new FieldList(2, 6));
            assertTrue(req.isMetBy(gp1));
            GlobalProperties gp2 = new GlobalProperties();
            gp2.setHashPartitioned(new FieldList(6, 2));
            assertTrue(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(2, null, Order.DESCENDING).appendOrdering(6, null, Order.ASCENDING));
            assertTrue(req.isMetBy(gp1));
            GlobalProperties gp2 = new GlobalProperties();
            gp2.setRangePartitioned(new Ordering(6, null, Order.DESCENDING).appendOrdering(2, null, Order.ASCENDING));
            assertTrue(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));
            assertTrue(req.isMetBy(gp4));
        }
        // match custom partitioning
        {
            GlobalProperties gp1 = new GlobalProperties();
            gp1.setCustomPartitioned(new FieldList(2, 6), new MockPartitioner());
            assertTrue(req.isMetBy(gp1));
            GlobalProperties gp2 = new GlobalProperties();
            gp2.setCustomPartitioned(new FieldList(6, 2), new MockPartitioner());
            assertTrue(req.isMetBy(gp2));
            GlobalProperties gp3 = new GlobalProperties();
            gp3.setCustomPartitioned(new FieldList(6, 1), new MockPartitioner());
            assertFalse(req.isMetBy(gp3));
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : FieldSet(org.apache.flink.api.common.operators.util.FieldSet) Ordering(org.apache.flink.api.common.operators.Ordering) FieldList(org.apache.flink.api.common.operators.util.FieldList) Test(org.junit.Test)

Example 64 with FieldList

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

the class LocalPropertiesFilteringTest method testSortingPreserved1.

@Test
public void testSortingPreserved1() {
    SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[] { "0;2;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(3, gFields.size());
    assertTrue(gFields.contains(0));
    assertTrue(gFields.contains(2));
    assertTrue(gFields.contains(5));
    assertNotNull(order);
    assertEquals(3, order.getNumberOfFields());
    assertEquals(2, order.getFieldNumber(0).intValue());
    assertEquals(0, order.getFieldNumber(1).intValue());
    assertEquals(5, 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 65 with FieldList

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

the class LocalPropertiesFilteringTest method testGroupingErased.

@Test
public void testGroupingErased() {
    SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[] { "0->4;2->0" }, null, null, tupleInfo, tupleInfo);
    LocalProperties lProps = LocalProperties.forGrouping(new FieldList(0, 2, 3));
    LocalProperties filtered = lProps.filterBySemanticProperties(sp, 0);
    assertNull(filtered.getGroupedFields());
    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)

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