Refine search
public boolean isCategory(PrimitiveCategory category) { return columnType.getCategory() == ObjectInspector.Category.PRIMITIVE && ((PrimitiveTypeInfo)columnType).getPrimitiveCategory() == category; }
public Field(TypeInfo typeInfo, DataTypePhysicalVariation dataTypePhysicalVariation) { Category category = typeInfo.getCategory(); if (category == Category.PRIMITIVE) { isPrimitive = true; primitiveCategory = ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory(); complexCategory = null; } else { isPrimitive = false; primitiveCategory = null; complexCategory = category; } this.typeInfo = typeInfo; this.dataTypePhysicalVariation = dataTypePhysicalVariation; complexTypeHelper = null; }
/** * returns true if both TypeInfos are of primitive type, and the primitive category matches. * @param ti1 * @param ti2 * @return */ public static boolean doPrimitiveCategoriesMatch(TypeInfo ti1, TypeInfo ti2) { if (ti1.getCategory() == Category.PRIMITIVE && ti2.getCategory() == Category.PRIMITIVE) { if (((PrimitiveTypeInfo)ti1).getPrimitiveCategory() == ((PrimitiveTypeInfo)ti2).getPrimitiveCategory()) { return true; } } return false; }
public static boolean isSupportedField(TypeInfo typeInfo) { if (typeInfo.getCategory() != Category.PRIMITIVE) return false; // not supported PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo) typeInfo; PrimitiveCategory pc = primitiveTypeInfo.getPrimitiveCategory(); if (!SUPPORTED_PRIMITIVES.contains(pc)) return false; // not supported return true; }
public static boolean isSupportedField(TypeInfo typeInfo) { if (typeInfo.getCategory() != Category.PRIMITIVE) return false; // not supported PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo) typeInfo; PrimitiveCategory pc = primitiveTypeInfo.getPrimitiveCategory(); if (!SUPPORTED_PRIMITIVES.contains(pc)) return false; // not supported return true; }
public static PrimitiveObjectInspector.PrimitiveCategory getReturnType(TypeInfo type) { if (type.getCategory() != ObjectInspector.Category.PRIMITIVE) { return null; } switch (((PrimitiveTypeInfo) type).getPrimitiveCategory()) { case BYTE: case SHORT: case INT: case LONG: return PrimitiveObjectInspector.PrimitiveCategory.LONG; case TIMESTAMP: case FLOAT: case DOUBLE: case STRING: case VARCHAR: case CHAR: return PrimitiveObjectInspector.PrimitiveCategory.DOUBLE; case DECIMAL: return PrimitiveObjectInspector.PrimitiveCategory.DECIMAL; } return null; }
public void init(TypeInfo[] typeInfos, int[] columnMap) throws HiveException { final int size = typeInfos.length; categories = new Category[size]; primitiveCategories = new PrimitiveCategory[size]; outputColumnNums = Arrays.copyOf(columnMap, size); TypeInfo typeInfo; for (int i = 0; i < typeInfos.length; i++) { typeInfo = typeInfos[i]; categories[i] = typeInfo.getCategory(); if (categories[i] == Category.PRIMITIVE) { primitiveCategories[i] = ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory(); } } }
public static boolean isImplicitVectorColumnConversion(TypeInfo fromTypeInfo, TypeInfo toTypeInfo) { if (fromTypeInfo.getCategory() == Category.PRIMITIVE && toTypeInfo.getCategory() == Category.PRIMITIVE) { PrimitiveCategory fromPrimitiveCategory = ((PrimitiveTypeInfo) fromTypeInfo).getPrimitiveCategory(); PrimitiveCategory toPrimitiveCategory = ((PrimitiveTypeInfo) toTypeInfo).getPrimitiveCategory(); PrimitiveCategory[] toPrimitiveCategories = implicitPrimitiveMap.get(fromPrimitiveCategory); if (toPrimitiveCategories != null) { for (PrimitiveCategory candidatePrimitiveCategory : toPrimitiveCategories) { if (candidatePrimitiveCategory == toPrimitiveCategory) { return true; } } } return false; } return false; } }
public static PrimitiveObjectInspector.PrimitiveCategory getReturnType(TypeInfo type) { if (type.getCategory() != ObjectInspector.Category.PRIMITIVE) { return null; } switch (((PrimitiveTypeInfo) type).getPrimitiveCategory()) { case BYTE: case SHORT: case INT: case LONG: return PrimitiveObjectInspector.PrimitiveCategory.LONG; case TIMESTAMP: case FLOAT: case DOUBLE: case STRING: case VARCHAR: case CHAR: return PrimitiveObjectInspector.PrimitiveCategory.DOUBLE; case DECIMAL: return PrimitiveObjectInspector.PrimitiveCategory.DECIMAL; } return null; }
public static boolean isImplicitVectorColumnConversion(TypeInfo fromTypeInfo, TypeInfo toTypeInfo) { if (fromTypeInfo.getCategory() == Category.PRIMITIVE && toTypeInfo.getCategory() == Category.PRIMITIVE) { PrimitiveCategory fromPrimitiveCategory = ((PrimitiveTypeInfo) fromTypeInfo).getPrimitiveCategory(); PrimitiveCategory toPrimitiveCategory = ((PrimitiveTypeInfo) toTypeInfo).getPrimitiveCategory(); PrimitiveCategory[] toPrimitiveCategories = implicitPrimitiveMap.get(fromPrimitiveCategory); if (toPrimitiveCategories != null) { for (PrimitiveCategory candidatePrimitiveCategory : toPrimitiveCategories) { if (candidatePrimitiveCategory == toPrimitiveCategory) { return true; } } } return false; } return false; } }
public static boolean isIntegerType(ExprNodeDesc expr) { TypeInfo typeInfo = expr.getTypeInfo(); if (typeInfo.getCategory() == ObjectInspector.Category.PRIMITIVE) { PrimitiveObjectInspector.PrimitiveCategory primitiveCategory = ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory(); if(primitiveCategory == PrimitiveCategory.INT || primitiveCategory == PrimitiveCategory.SHORT || primitiveCategory == PrimitiveCategory.BYTE || primitiveCategory == PrimitiveCategory.LONG){ return true; } } return false; }
private VectorExpression getIdentityForDateToDate(List<ExprNodeDesc> childExprs, TypeInfo returnTypeInfo) throws HiveException { if (childExprs.size() != 1) { return null; } TypeInfo childTypeInfo = childExprs.get(0).getTypeInfo(); if (childTypeInfo.getCategory() != Category.PRIMITIVE || ((PrimitiveTypeInfo) childTypeInfo).getPrimitiveCategory() != PrimitiveCategory.DATE) { return null; } if (returnTypeInfo.getCategory() != Category.PRIMITIVE || ((PrimitiveTypeInfo) returnTypeInfo).getPrimitiveCategory() != PrimitiveCategory.DATE) { return null; } return getIdentityExpression(childExprs); }
public void init(List<String> typeNames) throws HiveException { final int size = typeNames.size(); categories = new Category[size]; primitiveCategories = new PrimitiveCategory[size]; outputColumnNums = new int[size]; TypeInfo typeInfo; for (int i = 0; i < size; i++) { typeInfo = TypeInfoUtils.getTypeInfoFromTypeString(typeNames.get(i)); categories[i] = typeInfo.getCategory(); if (categories[i] == Category.PRIMITIVE) { primitiveCategories[i] = ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory(); } outputColumnNums[i] = i; } }
public void init(List<String> typeNames, int[] columnMap) throws HiveException { final int size = typeNames.size(); categories = new Category[size]; primitiveCategories = new PrimitiveCategory[size]; outputColumnNums = Arrays.copyOf(columnMap, size); TypeInfo typeInfo; for (int i = 0; i < size; i++) { typeInfo = TypeInfoUtils.getTypeInfoFromTypeString(typeNames.get(i)); categories[i] = typeInfo.getCategory(); if (categories[i] == Category.PRIMITIVE) { primitiveCategories[i] = ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory(); } } }
/** * Returns whether it is possible to implicitly convert an object of Class * from to Class to. */ public static boolean implicitConvertible(TypeInfo from, TypeInfo to) { if (from.equals(to)) { return true; } // Reimplemented to use PrimitiveCategory rather than TypeInfo, because // 2 TypeInfos from the same qualified type (varchar, decimal) should still be // seen as equivalent. if (from.getCategory() == Category.PRIMITIVE && to.getCategory() == Category.PRIMITIVE) { return implicitConvertible( ((PrimitiveTypeInfo) from).getPrimitiveCategory(), ((PrimitiveTypeInfo) to).getPrimitiveCategory()); } return false; } }
public static boolean isStringType(ExprNodeDesc expr) { TypeInfo typeInfo = expr.getTypeInfo(); if (typeInfo.getCategory() == ObjectInspector.Category.PRIMITIVE) { PrimitiveObjectInspector.PrimitiveCategory primitiveCategory = ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory(); if (PrimitiveObjectInspectorUtils.getPrimitiveGrouping(primitiveCategory) == PrimitiveObjectInspectorUtils.PrimitiveGrouping.STRING_GROUP) { return true; } } return false; } // Given an expression this method figures out if the type for the expression is integer
private static void validateAvroType(TypeInfo type, String columnName) { if (type.getCategory() == Category.MAP) { TypeInfo keyType = mapTypeInfo(type).getMapKeyTypeInfo(); if ((keyType.getCategory() != Category.PRIMITIVE) || (primitiveTypeInfo(keyType).getPrimitiveCategory() != PrimitiveCategory.STRING)) { throw new PrestoException(NOT_SUPPORTED, format("Column %s has a non-varchar map key, which is not supported by Avro", columnName)); } } else if (type.getCategory() == Category.PRIMITIVE) { PrimitiveCategory primitive = primitiveTypeInfo(type).getPrimitiveCategory(); if (primitive == PrimitiveCategory.BYTE) { throw new PrestoException(NOT_SUPPORTED, format("Column %s is tinyint, which is not supported by Avro. Use integer instead.", columnName)); } if (primitive == PrimitiveCategory.SHORT) { throw new PrestoException(NOT_SUPPORTED, format("Column %s is smallint, which is not supported by Avro. Use integer instead.", columnName)); } } }
/** * 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; }
private void initTargetEntry(int logicalColumnIndex, int projectionColumnNum, TypeInfo typeInfo) { isConvert[logicalColumnIndex] = false; projectionColumnNums[logicalColumnIndex] = projectionColumnNum; targetTypeInfos[logicalColumnIndex] = typeInfo; if (typeInfo.getCategory() == Category.PRIMITIVE) { final PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo) typeInfo; final PrimitiveCategory primitiveCategory = primitiveTypeInfo.getPrimitiveCategory(); switch (primitiveCategory) { case CHAR: maxLengths[logicalColumnIndex] = ((CharTypeInfo) primitiveTypeInfo).getLength(); break; case VARCHAR: maxLengths[logicalColumnIndex] = ((VarcharTypeInfo) primitiveTypeInfo).getLength(); break; default: // No additional data type specific setting. break; } } }
static String getScratchName(TypeInfo typeInfo) throws HiveException { // For now, leave DECIMAL precision/scale in the name so DecimalColumnVector scratch columns // don't need their precision/scale adjusted... if (typeInfo.getCategory() == Category.PRIMITIVE && ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory() == PrimitiveCategory.DECIMAL) { return typeInfo.getTypeName(); } Type columnVectorType = VectorizationContext.getColumnVectorTypeFromTypeInfo(typeInfo); return columnVectorType.name().toLowerCase(); }