Search in sources :

Example 1 with AllGroupWithPartialPreGroupProperties

use of org.apache.flink.optimizer.operators.AllGroupWithPartialPreGroupProperties in project flink by apache.

the class GroupReduceNode method initPossibleProperties.

private List<OperatorDescriptorSingle> initPossibleProperties(Partitioner<?> customPartitioner) {
    // see if an internal hint dictates the strategy to use
    final Configuration conf = getOperator().getParameters();
    final String localStrategy = conf.getString(Optimizer.HINT_LOCAL_STRATEGY, null);
    final boolean useCombiner;
    if (localStrategy != null) {
        if (Optimizer.HINT_LOCAL_STRATEGY_SORT.equals(localStrategy)) {
            useCombiner = false;
        } else if (Optimizer.HINT_LOCAL_STRATEGY_COMBINING_SORT.equals(localStrategy)) {
            if (!isCombineable()) {
                Optimizer.LOG.warn("Strategy hint for GroupReduce '" + getOperator().getName() + "' requires combinable reduce, but user function is not marked combinable.");
            }
            useCombiner = true;
        } else {
            throw new CompilerException("Invalid local strategy hint for match contract: " + localStrategy);
        }
    } else {
        useCombiner = isCombineable();
    }
    // check if we can work with a grouping (simple reducer), or if we need ordering because of a group order
    Ordering groupOrder = null;
    if (getOperator() instanceof GroupReduceOperatorBase) {
        groupOrder = getOperator().getGroupOrder();
        if (groupOrder != null && groupOrder.getNumberOfFields() == 0) {
            groupOrder = null;
        }
    }
    OperatorDescriptorSingle props = useCombiner ? (this.keys == null ? new AllGroupWithPartialPreGroupProperties() : new GroupReduceWithCombineProperties(this.keys, groupOrder, customPartitioner)) : (this.keys == null ? new AllGroupReduceProperties() : new GroupReduceProperties(this.keys, groupOrder, customPartitioner));
    return Collections.singletonList(props);
}
Also used : OperatorDescriptorSingle(org.apache.flink.optimizer.operators.OperatorDescriptorSingle) AllGroupWithPartialPreGroupProperties(org.apache.flink.optimizer.operators.AllGroupWithPartialPreGroupProperties) Configuration(org.apache.flink.configuration.Configuration) GroupReduceWithCombineProperties(org.apache.flink.optimizer.operators.GroupReduceWithCombineProperties) AllGroupReduceProperties(org.apache.flink.optimizer.operators.AllGroupReduceProperties) Ordering(org.apache.flink.api.common.operators.Ordering) GroupReduceOperatorBase(org.apache.flink.api.common.operators.base.GroupReduceOperatorBase) CompilerException(org.apache.flink.optimizer.CompilerException) GroupReduceProperties(org.apache.flink.optimizer.operators.GroupReduceProperties) AllGroupReduceProperties(org.apache.flink.optimizer.operators.AllGroupReduceProperties)

Aggregations

Ordering (org.apache.flink.api.common.operators.Ordering)1 GroupReduceOperatorBase (org.apache.flink.api.common.operators.base.GroupReduceOperatorBase)1 Configuration (org.apache.flink.configuration.Configuration)1 CompilerException (org.apache.flink.optimizer.CompilerException)1 AllGroupReduceProperties (org.apache.flink.optimizer.operators.AllGroupReduceProperties)1 AllGroupWithPartialPreGroupProperties (org.apache.flink.optimizer.operators.AllGroupWithPartialPreGroupProperties)1 GroupReduceProperties (org.apache.flink.optimizer.operators.GroupReduceProperties)1 GroupReduceWithCombineProperties (org.apache.flink.optimizer.operators.GroupReduceWithCombineProperties)1 OperatorDescriptorSingle (org.apache.flink.optimizer.operators.OperatorDescriptorSingle)1