当前位置: 首页>>代码示例>>Java>>正文


Java PrimitiveCategory.FLOAT属性代码示例

本文整理汇总了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());
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:29,代码来源:SortByFeatureUDFWrapper.java

示例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();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:32,代码来源:DataToSketchUDAF.java

示例3: GenericUDFTestFLOAT

public GenericUDFTestFLOAT() {
  super("testHiveUDFFLOAT", PrimitiveCategory.FLOAT);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:3,代码来源:HiveTestUDFImpls.java


注:本文中的org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory.FLOAT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。