Search in sources :

Example 1 with HashJoinBuildFirstProperties

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

the class JoinNode method makeJoinWithSolutionSet.

public void makeJoinWithSolutionSet(int solutionsetInputIndex) {
    OperatorDescriptorDual op;
    if (solutionsetInputIndex == 0) {
        op = new HashJoinBuildFirstProperties(this.keys1, this.keys2);
    } else if (solutionsetInputIndex == 1) {
        op = new HashJoinBuildSecondProperties(this.keys1, this.keys2);
    } else {
        throw new IllegalArgumentException();
    }
    this.dataProperties = Collections.singletonList(op);
}
Also used : HashJoinBuildFirstProperties(org.apache.flink.optimizer.operators.HashJoinBuildFirstProperties) HashJoinBuildSecondProperties(org.apache.flink.optimizer.operators.HashJoinBuildSecondProperties) OperatorDescriptorDual(org.apache.flink.optimizer.operators.OperatorDescriptorDual)

Example 2 with HashJoinBuildFirstProperties

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

the class JoinNode method getDataProperties.

private List<OperatorDescriptorDual> getDataProperties(InnerJoinOperatorBase<?, ?, ?, ?> joinOperatorBase, JoinHint joinHint, Partitioner<?> customPartitioner) {
    // see if an internal hint dictates the strategy to use
    Configuration conf = joinOperatorBase.getParameters();
    String localStrategy = conf.getString(Optimizer.HINT_LOCAL_STRATEGY, null);
    if (localStrategy != null) {
        final AbstractJoinDescriptor fixedDriverStrat;
        if (Optimizer.HINT_LOCAL_STRATEGY_SORT_BOTH_MERGE.equals(localStrategy) || Optimizer.HINT_LOCAL_STRATEGY_SORT_FIRST_MERGE.equals(localStrategy) || Optimizer.HINT_LOCAL_STRATEGY_SORT_SECOND_MERGE.equals(localStrategy) || Optimizer.HINT_LOCAL_STRATEGY_MERGE.equals(localStrategy)) {
            fixedDriverStrat = new SortMergeInnerJoinDescriptor(this.keys1, this.keys2);
        } else if (Optimizer.HINT_LOCAL_STRATEGY_HASH_BUILD_FIRST.equals(localStrategy)) {
            fixedDriverStrat = new HashJoinBuildFirstProperties(this.keys1, this.keys2);
        } else if (Optimizer.HINT_LOCAL_STRATEGY_HASH_BUILD_SECOND.equals(localStrategy)) {
            fixedDriverStrat = new HashJoinBuildSecondProperties(this.keys1, this.keys2);
        } else {
            throw new CompilerException("Invalid local strategy hint for match contract: " + localStrategy);
        }
        if (customPartitioner != null) {
            fixedDriverStrat.setCustomPartitioner(customPartitioner);
        }
        ArrayList<OperatorDescriptorDual> list = new ArrayList<OperatorDescriptorDual>();
        list.add(fixedDriverStrat);
        return list;
    } else {
        ArrayList<OperatorDescriptorDual> list = new ArrayList<OperatorDescriptorDual>();
        joinHint = joinHint == null ? JoinHint.OPTIMIZER_CHOOSES : joinHint;
        switch(joinHint) {
            case BROADCAST_HASH_FIRST:
                list.add(new HashJoinBuildFirstProperties(this.keys1, this.keys2, true, false, false));
                break;
            case BROADCAST_HASH_SECOND:
                list.add(new HashJoinBuildSecondProperties(this.keys1, this.keys2, false, true, false));
                break;
            case REPARTITION_HASH_FIRST:
                list.add(new HashJoinBuildFirstProperties(this.keys1, this.keys2, false, false, true));
                break;
            case REPARTITION_HASH_SECOND:
                list.add(new HashJoinBuildSecondProperties(this.keys1, this.keys2, false, false, true));
                break;
            case REPARTITION_SORT_MERGE:
                list.add(new SortMergeInnerJoinDescriptor(this.keys1, this.keys2, false, false, true));
                break;
            case OPTIMIZER_CHOOSES:
                list.add(new SortMergeInnerJoinDescriptor(this.keys1, this.keys2));
                list.add(new HashJoinBuildFirstProperties(this.keys1, this.keys2));
                list.add(new HashJoinBuildSecondProperties(this.keys1, this.keys2));
                break;
            default:
                throw new CompilerException("Unrecognized join hint: " + joinHint);
        }
        if (customPartitioner != null) {
            for (OperatorDescriptorDual descr : list) {
                ((AbstractJoinDescriptor) descr).setCustomPartitioner(customPartitioner);
            }
        }
        return list;
    }
}
Also used : Configuration(org.apache.flink.configuration.Configuration) HashJoinBuildFirstProperties(org.apache.flink.optimizer.operators.HashJoinBuildFirstProperties) HashJoinBuildSecondProperties(org.apache.flink.optimizer.operators.HashJoinBuildSecondProperties) ArrayList(java.util.ArrayList) CompilerException(org.apache.flink.optimizer.CompilerException) AbstractJoinDescriptor(org.apache.flink.optimizer.operators.AbstractJoinDescriptor) SortMergeInnerJoinDescriptor(org.apache.flink.optimizer.operators.SortMergeInnerJoinDescriptor) OperatorDescriptorDual(org.apache.flink.optimizer.operators.OperatorDescriptorDual)

Aggregations

HashJoinBuildFirstProperties (org.apache.flink.optimizer.operators.HashJoinBuildFirstProperties)2 HashJoinBuildSecondProperties (org.apache.flink.optimizer.operators.HashJoinBuildSecondProperties)2 OperatorDescriptorDual (org.apache.flink.optimizer.operators.OperatorDescriptorDual)2 ArrayList (java.util.ArrayList)1 Configuration (org.apache.flink.configuration.Configuration)1 CompilerException (org.apache.flink.optimizer.CompilerException)1 AbstractJoinDescriptor (org.apache.flink.optimizer.operators.AbstractJoinDescriptor)1 SortMergeInnerJoinDescriptor (org.apache.flink.optimizer.operators.SortMergeInnerJoinDescriptor)1