本文整理汇总了Java中org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory.FLOAT属性的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveCategory.FLOAT属性的具体用法?Java PrimitiveCategory.FLOAT怎么用?Java PrimitiveCategory.FLOAT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory
的用法示例。
在下文中一共展示了PrimitiveCategory.FLOAT属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
if (arguments.length != 1) {
throw new UDFArgumentLengthException(
"sorted_by_feature() has an single arguments: map<int, float> map");
}
switch (arguments[0].getCategory()) {
case MAP:
argumentOI = (MapObjectInspector) arguments[0];
ObjectInspector keyOI = argumentOI.getMapKeyObjectInspector();
ObjectInspector valueOI = argumentOI.getMapValueObjectInspector();
if (keyOI.getCategory().equals(Category.PRIMITIVE)
&& valueOI.getCategory().equals(Category.PRIMITIVE)) {
final PrimitiveCategory keyCategory = ((PrimitiveObjectInspector) keyOI).getPrimitiveCategory();
final PrimitiveCategory valueCategory = ((PrimitiveObjectInspector) valueOI).getPrimitiveCategory();
if (keyCategory == PrimitiveCategory.INT
&& valueCategory == PrimitiveCategory.FLOAT) {
break;
}
}
default:
throw new UDFArgumentTypeException(0, "Type mismatch: map");
}
return ObjectInspectorFactory.getStandardMapObjectInspector(
argumentOI.getMapKeyObjectInspector(), argumentOI.getMapValueObjectInspector());
}
示例2: getEvaluator
@Override
public GenericUDAFEvaluator getEvaluator(final GenericUDAFParameterInfo info) throws SemanticException {
final ObjectInspector[] inspectors = info.getParameterObjectInspectors();
if (inspectors.length < 2) {
throw new UDFArgumentException("Expected at least 2 arguments");
}
ObjectInspectorValidator.validateCategoryPrimitive(inspectors[0], 0);
// No validation of the value inspector since it can be anything.
// Override this method to validate if needed.
// nominal number of entries
if (inspectors.length > 2) {
ObjectInspectorValidator.validateIntegralParameter(inspectors[2], 2);
}
// sampling probability
if (inspectors.length > 3) {
ObjectInspectorValidator.validateCategoryPrimitive(inspectors[3], 3);
final PrimitiveObjectInspector primitiveInspector = (PrimitiveObjectInspector) inspectors[3];
if (primitiveInspector.getPrimitiveCategory() != PrimitiveCategory.FLOAT
&& primitiveInspector.getPrimitiveCategory() != PrimitiveCategory.DOUBLE) {
throw new UDFArgumentTypeException(3, "float or double value expected as parameter 4 but "
+ primitiveInspector.getPrimitiveCategory().name() + " was received");
}
}
checkExtraArguments(inspectors);
return createEvaluator();
}
示例3: GenericUDFTestFLOAT
public GenericUDFTestFLOAT() {
super("testHiveUDFFLOAT", PrimitiveCategory.FLOAT);
}