Search in sources :

Example 1 with ReusingBuildSecondReOpenableHashJoinIterator

use of org.apache.flink.runtime.operators.hash.ReusingBuildSecondReOpenableHashJoinIterator in project flink by apache.

the class AbstractCachedBuildSideJoinDriver method initialize.

@Override
public void initialize() throws Exception {
    TaskConfig config = this.taskContext.getTaskConfig();
    final Counter numRecordsIn = taskContext.getMetricGroup().getIOMetricGroup().getNumRecordsInCounter();
    TypeSerializer<IT1> serializer1 = this.taskContext.<IT1>getInputSerializer(0).getSerializer();
    TypeSerializer<IT2> serializer2 = this.taskContext.<IT2>getInputSerializer(1).getSerializer();
    TypeComparator<IT1> comparator1 = this.taskContext.getDriverComparator(0);
    TypeComparator<IT2> comparator2 = this.taskContext.getDriverComparator(1);
    MutableObjectIterator<IT1> input1 = new CountingMutableObjectIterator<>(this.taskContext.<IT1>getInput(0), numRecordsIn);
    MutableObjectIterator<IT2> input2 = new CountingMutableObjectIterator<>(this.taskContext.<IT2>getInput(1), numRecordsIn);
    TypePairComparatorFactory<IT1, IT2> pairComparatorFactory = this.taskContext.getTaskConfig().getPairComparatorFactory(this.taskContext.getUserCodeClassLoader());
    double availableMemory = config.getRelativeMemoryDriver();
    boolean hashJoinUseBitMaps = taskContext.getTaskManagerInfo().getConfiguration().getBoolean(ConfigConstants.RUNTIME_HASH_JOIN_BLOOM_FILTERS_KEY, ConfigConstants.DEFAULT_RUNTIME_HASH_JOIN_BLOOM_FILTERS);
    ExecutionConfig executionConfig = taskContext.getExecutionConfig();
    objectReuseEnabled = executionConfig.isObjectReuseEnabled();
    if (objectReuseEnabled) {
        if (buildSideIndex == 0 && probeSideIndex == 1) {
            matchIterator = new ReusingBuildFirstReOpenableHashJoinIterator<IT1, IT2, OT>(input1, input2, serializer1, comparator1, serializer2, comparator2, pairComparatorFactory.createComparator21(comparator1, comparator2), this.taskContext.getMemoryManager(), this.taskContext.getIOManager(), this.taskContext.getContainingTask(), availableMemory, false, false, hashJoinUseBitMaps);
        } else if (buildSideIndex == 1 && probeSideIndex == 0) {
            matchIterator = new ReusingBuildSecondReOpenableHashJoinIterator<IT1, IT2, OT>(input1, input2, serializer1, comparator1, serializer2, comparator2, pairComparatorFactory.createComparator12(comparator1, comparator2), this.taskContext.getMemoryManager(), this.taskContext.getIOManager(), this.taskContext.getContainingTask(), availableMemory, false, false, hashJoinUseBitMaps);
        } else {
            throw new Exception("Error: Inconsistent setup for repeatable hash join driver.");
        }
    } else {
        if (buildSideIndex == 0 && probeSideIndex == 1) {
            matchIterator = new NonReusingBuildFirstReOpenableHashJoinIterator<IT1, IT2, OT>(input1, input2, serializer1, comparator1, serializer2, comparator2, pairComparatorFactory.createComparator21(comparator1, comparator2), this.taskContext.getMemoryManager(), this.taskContext.getIOManager(), this.taskContext.getContainingTask(), availableMemory, false, false, hashJoinUseBitMaps);
        } else if (buildSideIndex == 1 && probeSideIndex == 0) {
            matchIterator = new NonReusingBuildSecondReOpenableHashJoinIterator<IT1, IT2, OT>(input1, input2, serializer1, comparator1, serializer2, comparator2, pairComparatorFactory.createComparator12(comparator1, comparator2), this.taskContext.getMemoryManager(), this.taskContext.getIOManager(), this.taskContext.getContainingTask(), availableMemory, false, false, hashJoinUseBitMaps);
        } else {
            throw new Exception("Error: Inconsistent setup for repeatable hash join driver.");
        }
    }
    this.matchIterator.open();
}
Also used : TaskConfig(org.apache.flink.runtime.operators.util.TaskConfig) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) NonReusingBuildSecondReOpenableHashJoinIterator(org.apache.flink.runtime.operators.hash.NonReusingBuildSecondReOpenableHashJoinIterator) ReusingBuildSecondReOpenableHashJoinIterator(org.apache.flink.runtime.operators.hash.ReusingBuildSecondReOpenableHashJoinIterator) Counter(org.apache.flink.metrics.Counter) CountingMutableObjectIterator(org.apache.flink.runtime.operators.util.metrics.CountingMutableObjectIterator) NonReusingBuildSecondReOpenableHashJoinIterator(org.apache.flink.runtime.operators.hash.NonReusingBuildSecondReOpenableHashJoinIterator)

Aggregations

ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)1 Counter (org.apache.flink.metrics.Counter)1 NonReusingBuildSecondReOpenableHashJoinIterator (org.apache.flink.runtime.operators.hash.NonReusingBuildSecondReOpenableHashJoinIterator)1 ReusingBuildSecondReOpenableHashJoinIterator (org.apache.flink.runtime.operators.hash.ReusingBuildSecondReOpenableHashJoinIterator)1 TaskConfig (org.apache.flink.runtime.operators.util.TaskConfig)1 CountingMutableObjectIterator (org.apache.flink.runtime.operators.util.metrics.CountingMutableObjectIterator)1