static private boolean isBooleanExpr(ExprNodeDesc expr) { return expr != null && expr instanceof ExprNodeConstantDesc && ((ExprNodeConstantDesc)expr).getTypeInfo() instanceof PrimitiveTypeInfo && ((PrimitiveTypeInfo)(((ExprNodeConstantDesc)expr).getTypeInfo())). getTypeName().equals(serdeConstants.BOOLEAN_TYPE_NAME); } static private boolean isTrueExpr(ExprNodeDesc expr) {
static private boolean isBooleanExpr(ExprNodeDesc expr) { return expr != null && expr instanceof ExprNodeConstantDesc && ((ExprNodeConstantDesc)expr).getTypeInfo() instanceof PrimitiveTypeInfo && ((PrimitiveTypeInfo)(((ExprNodeConstantDesc)expr).getTypeInfo())). getTypeName().equals(serdeConstants.BOOLEAN_TYPE_NAME); } static private boolean isTrueExpr(ExprNodeDesc expr) {
/** * Set this argument to a constant value extracted from the * expression tree. */ public void setConstant(ExprNodeConstantDesc expr) { isConstant = true; if (expr != null) { if (expr.getTypeInfo().getCategory() == Category.PRIMITIVE) { PrimitiveCategory primitiveCategory = ((PrimitiveTypeInfo) expr.getTypeInfo()) .getPrimitiveCategory(); if (primitiveCategory == PrimitiveCategory.VOID) { // Otherwise we'd create a NullWritable and that isn't what we want. expr = null; } } } constExpr = expr; }
/** * Set this argument to a constant value extracted from the * expression tree. */ public void setConstant(ExprNodeConstantDesc expr) { isConstant = true; if (expr != null) { if (expr.getTypeInfo().getCategory() == Category.PRIMITIVE) { PrimitiveCategory primitiveCategory = ((PrimitiveTypeInfo) expr.getTypeInfo()) .getPrimitiveCategory(); if (primitiveCategory == PrimitiveCategory.VOID) { // Otherwise we'd create a NullWritable and that isn't what we want. expr = null; } } } constExpr = expr; }
@Override public boolean isSame(Object o) { if (!(o instanceof ExprNodeConstantDesc)) { return false; } ExprNodeConstantDesc dest = (ExprNodeConstantDesc) o; if (!typeInfo.equals(dest.getTypeInfo())) { return false; } if (value == null) { if (dest.getValue() != null) { return false; } } else if (!value.equals(dest.getValue())) { return false; } return true; }
@Override public boolean isSame(Object o) { if (!(o instanceof ExprNodeConstantDesc)) { return false; } ExprNodeConstantDesc dest = (ExprNodeConstantDesc) o; if (!typeInfo.equals(dest.getTypeInfo())) { return false; } if (value == null) { if (dest.getValue() != null) { return false; } } else if (!value.equals(dest.getValue())) { return false; } return true; }
private static boolean sameTypeIndexSearchConditions(List<IndexSearchCondition> searchConditions) { for (IndexSearchCondition isc : searchConditions) { if (!isc.getColumnDesc().getTypeInfo().equals(isc.getConstantDesc().getTypeInfo())) { return false; } } return true; } }
private static List<ExprNodeDesc> asListOfNodes(ExprNodeDesc desc) { ExprNodeDesc valueDesc = desc; if (ExprNodeDescUtils.isStructUDF(desc)) { List<ExprNodeDesc> valueChilds = ((ExprNodeGenericFuncDesc) valueDesc).getChildren(); for (ExprNodeDesc exprNodeDesc : valueChilds) { if (!isSafeExpression(exprNodeDesc)) { return null; } } return valueChilds; } if (ExprNodeDescUtils.isConstantStruct(valueDesc)) { ExprNodeConstantDesc valueConstDesc = (ExprNodeConstantDesc) valueDesc; List<Object> oldValues = (List<Object>) valueConstDesc.getValue(); StructTypeInfo structTypeInfo = (StructTypeInfo) valueConstDesc.getTypeInfo(); ArrayList<TypeInfo> structFieldInfos = structTypeInfo.getAllStructFieldTypeInfos(); List<ExprNodeDesc> ret = new ArrayList<>(); for (int i = 0; i < oldValues.size(); i++) { ret.add(new ExprNodeConstantDesc(structFieldInfos.get(i), oldValues.get(i))); } return ret; } if (isSafeExpression(desc)) { return Lists.newArrayList(desc); } return null; }
private Object getVectorTypeScalarValue(ExprNodeConstantDesc constDesc) throws HiveException { String t = constDesc.getTypeInfo().getTypeName(); VectorExpression.Type type = VectorExpression.Type.getValue(t); Object scalarValue = getScalarValue(constDesc); switch (type) { case DATE: return new Long(DateWritable.dateToDays((Date) scalarValue)); case INTERVAL_YEAR_MONTH: return ((HiveIntervalYearMonth) scalarValue).getTotalMonths(); default: return scalarValue; } }
ExprNodeConstantDesc constantChild = (ExprNodeConstantDesc) child; List<?> items = (List<?>) constantChild.getWritableObjectInspector().getWritableConstantValue(); List<TypeInfo> structTypes = ((StructTypeInfo) constantChild.getTypeInfo()).getAllStructFieldTypeInfos(); for (int j = 0; j < structTypes.size(); j++) { ExprNodeConstantDesc constant = new ExprNodeConstantDesc(structTypes.get(j), items.get(j));
LOG.debug("Filter " + udf + " is identified as a value assignment, propagate it."); if (!v.getTypeInfo().equals(ci.getType())) { v = typeCast(v, ci.getType(), true);
if ( constantExpr.getTypeInfo() != TypeInfoFactory.intTypeInfo ) { return null;
if ( constantExpr.getTypeInfo() != TypeInfoFactory.intTypeInfo ) { return null;
if (constExpr != null) { Object constantValue = constExpr.getValue(); TypeInfo typeInfo = constExpr.getTypeInfo(); ObjectInspector objectInspector = TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(typeInfo);
private Object getVectorTypeScalarValue(ExprNodeConstantDesc constDesc) throws HiveException { TypeInfo typeInfo = constDesc.getTypeInfo(); PrimitiveCategory primitiveCategory = ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory(); Object scalarValue = getScalarValue(constDesc); switch (primitiveCategory) { case DATE: return (long) DateWritableV2.dateToDays((Date) scalarValue); case TIMESTAMP: return ((org.apache.hadoop.hive.common.type.Timestamp) scalarValue).toSqlTimestamp(); case INTERVAL_YEAR_MONTH: return ((HiveIntervalYearMonth) scalarValue).getTotalMonths(); default: return scalarValue; } }
LOG.debug("Filter " + udf + " is identified as a value assignment, propagate it."); if (!v.getTypeInfo().equals(ci.getType())) { v = typeCast(v, ci.getType(), true);
ExprNodeConstantDesc constantChild = (ExprNodeConstantDesc) child; List<?> items = (List<?>) constantChild.getWritableObjectInspector().getWritableConstantValue(); List<TypeInfo> structTypes = ((StructTypeInfo) constantChild.getTypeInfo()).getAllStructFieldTypeInfos(); for (int j = 0; j < structTypes.size(); j++) { ExprNodeConstantDesc constant = new ExprNodeConstantDesc(structTypes.get(j), items.get(j));
List<ExprNodeDesc> columnChilds = ((ExprNodeGenericFuncDesc) columnDesc).getChildren(); ExprNodeConstantDesc valueConstDesc = (ExprNodeConstantDesc) valueDesc; StructTypeInfo structTypeInfo = (StructTypeInfo) valueConstDesc.getTypeInfo(); ArrayList<TypeInfo> structFieldInfos = structTypeInfo.getAllStructFieldTypeInfos(); ArrayList<TypeInfo> newStructFieldInfos = new ArrayList<>();
public void prepareConstant() { final Object writableValue; if (constExpr != null) { PrimitiveCategory pc = ((PrimitiveTypeInfo) constExpr.getTypeInfo()) .getPrimitiveCategory(); // Convert from Java to Writable writableValue = PrimitiveObjectInspectorFactory .getPrimitiveJavaObjectInspector(pc).getPrimitiveWritableObject( constExpr.getValue()); } else { writableValue = null; } constObjVal = new GenericUDF.DeferredJavaObject(writableValue); }
if (desc instanceof ExprNodeConstantDesc) { ExprNodeConstantDesc constant = (ExprNodeConstantDesc) exprs.get(i); if (!constant.getTypeInfo().equals(oldExprs.get(i).getTypeInfo())) { constant = typeCast(constant, oldExprs.get(i).getTypeInfo()); if (constant == null) { if (constant.getTypeInfo().getCategory() != Category.PRIMITIVE) { PrimitiveTypeInfo pti = (PrimitiveTypeInfo) constant.getTypeInfo(); Object writableValue = null == value ? value : PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(pti) if (constant.getTypeInfo().getCategory() != Category.PRIMITIVE) { (PrimitiveTypeInfo) constant.getTypeInfo()).getPrimitiveWritableObject(constant.getValue()); arguments[i] = new DeferredJavaObject(writableValue); argois[i] = ObjectInspectorUtils.getConstantObjectInspector(constant.getWritableObjectInspector(), writableValue);