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);
}
Aggregations