本文整理汇总了Java中org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory.DECIMAL属性的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveCategory.DECIMAL属性的具体用法?Java PrimitiveCategory.DECIMAL怎么用?Java PrimitiveCategory.DECIMAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory
的用法示例。
在下文中一共展示了PrimitiveCategory.DECIMAL属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMajorTypeFromHiveTypeInfo
public static MajorType getMajorTypeFromHiveTypeInfo(final TypeInfo typeInfo, final OptionManager options) {
switch (typeInfo.getCategory()) {
case PRIMITIVE: {
PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo) typeInfo;
MinorType minorType = HiveUtilities.getMinorTypeFromHivePrimitiveTypeInfo(primitiveTypeInfo, options);
MajorType.Builder typeBuilder = MajorType.newBuilder().setMinorType(minorType)
.setMode(DataMode.OPTIONAL); // Hive columns (both regular and partition) could have null values
if (primitiveTypeInfo.getPrimitiveCategory() == PrimitiveCategory.DECIMAL) {
DecimalTypeInfo decimalTypeInfo = (DecimalTypeInfo) primitiveTypeInfo;
typeBuilder.setPrecision(decimalTypeInfo.precision())
.setScale(decimalTypeInfo.scale()).build();
}
return typeBuilder.build();
}
case LIST:
case MAP:
case STRUCT:
case UNION:
default:
throwUnsupportedHiveDataTypeError(typeInfo.getCategory().toString());
}
return null;
}
示例2: create
public static HiveFieldConverter create(TypeInfo typeInfo, FragmentContext fragmentContext)
throws IllegalAccessException, InstantiationException {
switch (typeInfo.getCategory()) {
case PRIMITIVE:
final PrimitiveCategory pCat = ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory();
if (pCat != PrimitiveCategory.DECIMAL) {
Class<? extends HiveFieldConverter> clazz = primMap.get(pCat);
if (clazz != null) {
return clazz.newInstance();
}
} else {
// For decimal, based on precision return appropriate converter.
DecimalTypeInfo decimalTypeInfo = (DecimalTypeInfo) typeInfo;
int precision = decimalTypeInfo.precision();
int scale = decimalTypeInfo.scale();
if (precision <= 9) {
return new Decimal9(precision, scale);
} else if (precision <= 18) {
return new Decimal18(precision, scale);
} else if (precision <= 28) {
return new Decimal28(precision, scale, fragmentContext);
} else {
return new Decimal38(precision, scale, fragmentContext);
}
}
throwUnsupportedHiveDataTypeError(pCat.toString());
break;
case LIST:
case MAP:
case STRUCT:
case UNION:
default:
throwUnsupportedHiveDataTypeError(typeInfo.getCategory().toString());
}
return null;
}
示例3: getEvaluator
@Override
public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException {
checkArgumentTypes(parameters);
if (((PrimitiveTypeInfo) parameters[1]).getPrimitiveCategory() == PrimitiveCategory.DECIMAL) {
return new EvaluatorDecimal();
} else {
return new EvaluatorDouble();
}
}
示例4: getMajorTypeFromHiveTypeInfo
public static MajorType getMajorTypeFromHiveTypeInfo(final TypeInfo typeInfo, final OptionManager options) {
switch (typeInfo.getCategory()) {
case PRIMITIVE: {
PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo) typeInfo;
MinorType minorType = getMinorTypeFromHivePrimitiveTypeInfo(primitiveTypeInfo, options);
MajorType.Builder typeBuilder = MajorType.newBuilder().setMinorType(getMinorTypeFromArrowMinorType(minorType))
.setMode(DataMode.OPTIONAL); // Hive columns (both regular and partition) could have null values
if (primitiveTypeInfo.getPrimitiveCategory() == PrimitiveCategory.DECIMAL) {
DecimalTypeInfo decimalTypeInfo = (DecimalTypeInfo) primitiveTypeInfo;
typeBuilder.setPrecision(decimalTypeInfo.precision())
.setScale(decimalTypeInfo.scale()).build();
}
return typeBuilder.build();
}
case LIST:
case MAP:
case STRUCT:
case UNION:
default:
HiveUtilities.throwUnsupportedHiveDataTypeError(typeInfo.getCategory().toString());
}
return null;
}
示例5: create
public static HiveFieldConverter create(TypeInfo typeInfo, OperatorContext context)
throws IllegalAccessException, InstantiationException {
switch (typeInfo.getCategory()) {
case PRIMITIVE:
final PrimitiveCategory pCat = ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory();
if (pCat != PrimitiveCategory.DECIMAL) {
Class<? extends HiveFieldConverter> clazz = primMap.get(pCat);
if (clazz != null) {
return clazz.newInstance();
}
} else {
// For decimal, based on precision return appropriate converter.
DecimalTypeInfo decimalTypeInfo = (DecimalTypeInfo) typeInfo;
int precision = decimalTypeInfo.precision();
int scale = decimalTypeInfo.scale();
return new Decimal(precision, scale, context);
}
throwUnsupportedHiveDataTypeError(pCat.toString());
break;
case LIST:
case MAP:
case STRUCT:
case UNION:
default:
throwUnsupportedHiveDataTypeError(typeInfo.getCategory().toString());
}
return null;
}
示例6: GenericUDFTestDECIMAL
public GenericUDFTestDECIMAL() {
super("testHiveUDFDECIMAL", PrimitiveCategory.DECIMAL, PrimitiveCategory.VARCHAR);
}