Search in sources :

Example 1 with FilterConstantBooleanVectorExpression

use of org.apache.hadoop.hive.ql.exec.vector.expressions.FilterConstantBooleanVectorExpression in project hive by apache.

the class VectorizationContext method getConstantVectorExpression.

private VectorExpression getConstantVectorExpression(Object constantValue, TypeInfo typeInfo, VectorExpressionDescriptor.Mode mode) throws HiveException {
    String typeName = typeInfo.getTypeName();
    VectorExpressionDescriptor.ArgumentType vectorArgType = VectorExpressionDescriptor.ArgumentType.fromHiveTypeName(typeName);
    if (vectorArgType == VectorExpressionDescriptor.ArgumentType.NONE) {
        throw new HiveException("No vector argument type for type name " + typeName);
    }
    int outCol = -1;
    if (mode == VectorExpressionDescriptor.Mode.PROJECTION) {
        outCol = ocm.allocateOutputColumn(typeInfo);
    }
    if (constantValue == null) {
        if (typeInfo.getCategory() != Category.PRIMITIVE) {
            throw new HiveException("Complex type constants (" + typeInfo.getCategory() + ") not supported for type name " + typeName);
        }
        if (mode == VectorExpressionDescriptor.Mode.FILTER) {
            return new FilterConstantBooleanVectorExpression(0);
        } else {
            return new ConstantVectorExpression(outCol, typeInfo, true);
        }
    }
    // Boolean is special case.
    if (typeName.equalsIgnoreCase("boolean")) {
        if (mode == VectorExpressionDescriptor.Mode.FILTER) {
            if ((Boolean) constantValue) {
                return new FilterConstantBooleanVectorExpression(1);
            } else {
                return new FilterConstantBooleanVectorExpression(0);
            }
        } else {
            if ((Boolean) constantValue) {
                return new ConstantVectorExpression(outCol, 1, typeInfo);
            } else {
                return new ConstantVectorExpression(outCol, 0, typeInfo);
            }
        }
    }
    return ConstantVectorExpression.create(outCol, constantValue, typeInfo);
}
Also used : HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) CastDecimalToString(org.apache.hadoop.hive.ql.exec.vector.expressions.CastDecimalToString) CastLongToString(org.apache.hadoop.hive.ql.exec.vector.expressions.CastLongToString) CastFloatToString(org.apache.hadoop.hive.ql.exec.vector.expressions.CastFloatToString) CastDateToString(org.apache.hadoop.hive.ql.exec.vector.expressions.CastDateToString) CastTimestampToString(org.apache.hadoop.hive.ql.exec.vector.expressions.CastTimestampToString) CastDoubleToString(org.apache.hadoop.hive.ql.exec.vector.expressions.CastDoubleToString) CastBooleanToStringViaLongToString(org.apache.hadoop.hive.ql.exec.vector.expressions.CastBooleanToStringViaLongToString) FilterConstantBooleanVectorExpression(org.apache.hadoop.hive.ql.exec.vector.expressions.FilterConstantBooleanVectorExpression) ConstantVectorExpression(org.apache.hadoop.hive.ql.exec.vector.expressions.ConstantVectorExpression) CastStringToBoolean(org.apache.hadoop.hive.ql.exec.vector.expressions.CastStringToBoolean) ArgumentType(org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor.ArgumentType)

Aggregations

ArgumentType (org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor.ArgumentType)1 CastBooleanToStringViaLongToString (org.apache.hadoop.hive.ql.exec.vector.expressions.CastBooleanToStringViaLongToString)1 CastDateToString (org.apache.hadoop.hive.ql.exec.vector.expressions.CastDateToString)1 CastDecimalToString (org.apache.hadoop.hive.ql.exec.vector.expressions.CastDecimalToString)1 CastDoubleToString (org.apache.hadoop.hive.ql.exec.vector.expressions.CastDoubleToString)1 CastFloatToString (org.apache.hadoop.hive.ql.exec.vector.expressions.CastFloatToString)1 CastLongToString (org.apache.hadoop.hive.ql.exec.vector.expressions.CastLongToString)1 CastStringToBoolean (org.apache.hadoop.hive.ql.exec.vector.expressions.CastStringToBoolean)1 CastTimestampToString (org.apache.hadoop.hive.ql.exec.vector.expressions.CastTimestampToString)1 ConstantVectorExpression (org.apache.hadoop.hive.ql.exec.vector.expressions.ConstantVectorExpression)1 FilterConstantBooleanVectorExpression (org.apache.hadoop.hive.ql.exec.vector.expressions.FilterConstantBooleanVectorExpression)1 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)1