Search in sources :

Example 1 with DateType

use of com.facebook.presto.spi.type.DateType in project presto by prestodb.

the class InCodeGenerator method checkSwitchGenerationCase.

@VisibleForTesting
static SwitchGenerationCase checkSwitchGenerationCase(Type type, List<RowExpression> values) {
    if (values.size() > 32) {
        // * Benchmark shows performance of SET_CONTAINS is better at 50, but similar at 25.
        return SwitchGenerationCase.SET_CONTAINS;
    }
    if (!(type instanceof IntegerType || type instanceof BigintType || type instanceof DateType)) {
        return SwitchGenerationCase.HASH_SWITCH;
    }
    for (RowExpression expression : values) {
        // Same argument applies for nulls.
        if (!(expression instanceof ConstantExpression)) {
            continue;
        }
        Object constant = ((ConstantExpression) expression).getValue();
        if (constant == null) {
            continue;
        }
        long longConstant = ((Number) constant).longValue();
        if (longConstant < Integer.MIN_VALUE || longConstant > Integer.MAX_VALUE) {
            return SwitchGenerationCase.HASH_SWITCH;
        }
    }
    return SwitchGenerationCase.DIRECT_SWITCH;
}
Also used : IntegerType(com.facebook.presto.spi.type.IntegerType) ConstantExpression(com.facebook.presto.sql.relational.ConstantExpression) RowExpression(com.facebook.presto.sql.relational.RowExpression) DateType(com.facebook.presto.spi.type.DateType) BigintType(com.facebook.presto.spi.type.BigintType) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

BigintType (com.facebook.presto.spi.type.BigintType)1 DateType (com.facebook.presto.spi.type.DateType)1 IntegerType (com.facebook.presto.spi.type.IntegerType)1 ConstantExpression (com.facebook.presto.sql.relational.ConstantExpression)1 RowExpression (com.facebook.presto.sql.relational.RowExpression)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1