Search in sources :

Example 1 with Comparator

use of org.apache.drill.exec.physical.impl.common.Comparator in project drill by apache.

the class HashJoinBatch method setupHashTable.

private void setupHashTable() {
    List<Comparator> comparators = Lists.newArrayListWithExpectedSize(conditions.size());
    conditions.forEach(cond -> comparators.add(JoinUtils.checkAndReturnSupportedJoinComparator(cond)));
    if (skipHashTableBuild) {
        return;
    }
    // Setup the hash table configuration object
    List<NamedExpression> leftExpr = new ArrayList<>(conditions.size());
    // Create named expressions from the conditions
    for (int i = 0; i < conditions.size(); i++) {
        leftExpr.add(new NamedExpression(conditions.get(i).getLeft(), new FieldReference("probe_side_" + i)));
    }
    // Set the left named expression to be null if the probe batch is empty.
    if (leftUpstream != IterOutcome.OK_NEW_SCHEMA && leftUpstream != IterOutcome.OK) {
        leftExpr = null;
    } else {
        if (probeBatch.getSchema().getSelectionVectorMode() != BatchSchema.SelectionVectorMode.NONE) {
            throw UserException.internalError(null).message("Hash join does not support probe batch with selection vectors.").addContext("Probe batch has selection mode", (probeBatch.getSchema().getSelectionVectorMode()).toString()).build(logger);
        }
    }
    HashTableConfig htConfig = new HashTableConfig((int) context.getOptions().getOption(ExecConstants.MIN_HASH_TABLE_SIZE), true, HashTable.DEFAULT_LOAD_FACTOR, rightExpr, leftExpr, comparators, joinControl.asInt());
    // Create the chained hash table
    baseHashTable = new ChainedHashTable(htConfig, context, allocator, buildBatch, probeBatch, null);
    if (enableRuntimeFilter) {
        setupHash64(htConfig);
    }
}
Also used : HashTableConfig(org.apache.drill.exec.physical.impl.common.HashTableConfig) FieldReference(org.apache.drill.common.expression.FieldReference) NamedExpression(org.apache.drill.common.logical.data.NamedExpression) ArrayList(java.util.ArrayList) ChainedHashTable(org.apache.drill.exec.physical.impl.common.ChainedHashTable) Comparator(org.apache.drill.exec.physical.impl.common.Comparator)

Aggregations

ArrayList (java.util.ArrayList)1 FieldReference (org.apache.drill.common.expression.FieldReference)1 NamedExpression (org.apache.drill.common.logical.data.NamedExpression)1 ChainedHashTable (org.apache.drill.exec.physical.impl.common.ChainedHashTable)1 Comparator (org.apache.drill.exec.physical.impl.common.Comparator)1 HashTableConfig (org.apache.drill.exec.physical.impl.common.HashTableConfig)1