Search in sources :

Example 21 with Ordering

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

the class RequestedLocalPropertiesFilteringTest method testOrderErased.

@Test
public void testOrderErased() {
    SingleInputSemanticProperties sProps = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sProps, new String[] { "1; 4" }, null, null, tupleInfo, tupleInfo);
    Ordering o = new Ordering();
    o.appendOrdering(4, LongValue.class, Order.DESCENDING);
    o.appendOrdering(1, IntValue.class, Order.ASCENDING);
    o.appendOrdering(6, ByteValue.class, Order.DESCENDING);
    RequestedLocalProperties rlProp = new RequestedLocalProperties();
    rlProp.setOrdering(o);
    RequestedLocalProperties filtered = rlProp.filterBySemanticProperties(sProps, 0);
    assertNull(filtered);
}
Also used : Ordering(org.apache.flink.api.common.operators.Ordering) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) Test(org.junit.Test)

Example 22 with Ordering

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

the class CoGroupNode method initializeDataProperties.

private List<OperatorDescriptorDual> initializeDataProperties(Partitioner<?> customPartitioner) {
    Ordering groupOrder1 = null;
    Ordering groupOrder2 = null;
    CoGroupOperatorBase<?, ?, ?, ?> cgc = getOperator();
    groupOrder1 = cgc.getGroupOrderForInputOne();
    groupOrder2 = cgc.getGroupOrderForInputTwo();
    if (groupOrder1 != null && groupOrder1.getNumberOfFields() == 0) {
        groupOrder1 = null;
    }
    if (groupOrder2 != null && groupOrder2.getNumberOfFields() == 0) {
        groupOrder2 = null;
    }
    CoGroupDescriptor descr = new CoGroupDescriptor(this.keys1, this.keys2, groupOrder1, groupOrder2);
    if (customPartitioner != null) {
        descr.setCustomPartitioner(customPartitioner);
    }
    return Collections.<OperatorDescriptorDual>singletonList(descr);
}
Also used : CoGroupDescriptor(org.apache.flink.optimizer.operators.CoGroupDescriptor) Ordering(org.apache.flink.api.common.operators.Ordering) OperatorDescriptorDual(org.apache.flink.optimizer.operators.OperatorDescriptorDual)

Example 23 with Ordering

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

the class CoGroupRawNode method initializeDataProperties.

private List<OperatorDescriptorDual> initializeDataProperties() {
    Ordering groupOrder1 = null;
    Ordering groupOrder2 = null;
    CoGroupRawOperatorBase<?, ?, ?, ?> cgc = getOperator();
    groupOrder1 = cgc.getGroupOrderForInputOne();
    groupOrder2 = cgc.getGroupOrderForInputTwo();
    if (groupOrder1 != null && groupOrder1.getNumberOfFields() == 0) {
        groupOrder1 = null;
    }
    if (groupOrder2 != null && groupOrder2.getNumberOfFields() == 0) {
        groupOrder2 = null;
    }
    return Collections.<OperatorDescriptorDual>singletonList(new CoGroupRawDescriptor(this.keys1, this.keys2, groupOrder1, groupOrder2));
}
Also used : CoGroupRawDescriptor(org.apache.flink.optimizer.operators.CoGroupRawDescriptor) Ordering(org.apache.flink.api.common.operators.Ordering) OperatorDescriptorDual(org.apache.flink.optimizer.operators.OperatorDescriptorDual)

Example 24 with Ordering

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

the class DataSinkNode method computeInterestingPropertiesForInputs.

@Override
public void computeInterestingPropertiesForInputs(CostEstimator estimator) {
    final InterestingProperties iProps = new InterestingProperties();
    {
        final RequestedGlobalProperties partitioningProps = new RequestedGlobalProperties();
        iProps.addGlobalProperties(partitioningProps);
    }
    {
        final Ordering localOrder = getOperator().getLocalOrder();
        final RequestedLocalProperties orderProps = new RequestedLocalProperties();
        if (localOrder != null) {
            orderProps.setOrdering(localOrder);
        }
        iProps.addLocalProperties(orderProps);
    }
    this.input.setInterestingProperties(iProps);
}
Also used : RequestedGlobalProperties(org.apache.flink.optimizer.dataproperties.RequestedGlobalProperties) RequestedLocalProperties(org.apache.flink.optimizer.dataproperties.RequestedLocalProperties) Ordering(org.apache.flink.api.common.operators.Ordering) InterestingProperties(org.apache.flink.optimizer.dataproperties.InterestingProperties)

Example 25 with Ordering

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

the class DataSourceNode method setDataPropertiesFromSplitProperties.

private void setDataPropertiesFromSplitProperties(SplitDataProperties splitProps) {
    // set global properties
    int[] partitionKeys = splitProps.getSplitPartitionKeys();
    Partitioner<?> partitioner = splitProps.getSplitPartitioner();
    if (partitionKeys != null && partitioner != null) {
        this.gprops.setCustomPartitioned(new FieldList(partitionKeys), partitioner);
    } else if (partitionKeys != null) {
        this.gprops.setAnyPartitioning(new FieldList(partitionKeys));
    }
    // set local properties
    int[] groupingKeys = splitProps.getSplitGroupKeys();
    Ordering ordering = splitProps.getSplitOrder();
    // adapt split grouping and sorting
    if (ordering != null) {
        // sorting falls back to grouping because a source can read multiple,
        // randomly assigned splits
        groupingKeys = ordering.getFieldPositions();
    }
    if (groupingKeys != null && partitionKeys != null) {
        // check if grouping is also valid across splits, i.e., whether grouping keys are
        // valid superset of partition keys
        boolean allFieldsIncluded = true;
        for (int i : partitionKeys) {
            boolean fieldIncluded = false;
            for (int j : groupingKeys) {
                if (i == j) {
                    fieldIncluded = true;
                    break;
                }
            }
            if (!fieldIncluded) {
                allFieldsIncluded = false;
                break;
            }
        }
        if (allFieldsIncluded) {
            this.lprops = LocalProperties.forGrouping(new FieldList(groupingKeys));
        } else {
            this.lprops = new LocalProperties();
        }
    } else {
        this.lprops = new LocalProperties();
    }
}
Also used : Ordering(org.apache.flink.api.common.operators.Ordering) LocalProperties(org.apache.flink.optimizer.dataproperties.LocalProperties) FieldList(org.apache.flink.api.common.operators.util.FieldList)

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