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


Java PrimitiveCategory.DOUBLE属性代码示例

本文整理汇总了Java中org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory.DOUBLE属性的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveCategory.DOUBLE属性的具体用法?Java PrimitiveCategory.DOUBLE怎么用?Java PrimitiveCategory.DOUBLE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory的用法示例。


在下文中一共展示了PrimitiveCategory.DOUBLE属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialize

@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    if (arguments.length != 1) {
        throw new UDFArgumentLengthException(
            "add_feature_index() has an single arguments: array<double> features");
    }

    switch (arguments[0].getCategory()) {
        case LIST:
            argumentOI = (ListObjectInspector) arguments[0];
            ObjectInspector elmOI = argumentOI.getListElementObjectInspector();
            if (elmOI.getCategory().equals(Category.PRIMITIVE)) {
                if (((PrimitiveObjectInspector) elmOI).getPrimitiveCategory() == PrimitiveCategory.DOUBLE) {
                    break;
                }
            }
        default:
            throw new UDFArgumentTypeException(0, "Type mismatch: features");
    }

    return ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.javaStringObjectInspector);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:22,代码来源:AddFeatureIndexUDFWrapper.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: 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);

  int numValues = 0;
  while (numValues + 1 < inspectors.length) {
    ObjectInspectorValidator.validateCategoryPrimitive(inspectors[numValues + 1], numValues + 1);
    final PrimitiveObjectInspector primitiveInspector =
        (PrimitiveObjectInspector) inspectors[numValues + 1];
    if (primitiveInspector.getPrimitiveCategory() != PrimitiveCategory.DOUBLE) { break; }
    numValues++;
  }
  if (numValues == 0) {
    throw new UDFArgumentException("Expected at least 1 double value");
  }

  // nominal number of entries
  if (inspectors.length > numValues + 1) {
    ObjectInspectorValidator.validateIntegralParameter(inspectors[numValues + 1], numValues + 1);
  }

  // sampling probability
  if (inspectors.length > numValues + 2) {
    ObjectInspectorValidator.validateGivenPrimitiveCategory(inspectors[numValues + 2],
        numValues + 2, PrimitiveCategory.FLOAT);
  }

  // there must be nothing after sampling probability
  if (inspectors.length > numValues + 3) {
    throw new UDFArgumentException("Unexpected argument " + (numValues + 4));
  }

  return new DataToArrayOfDoublesSketchEvaluator();
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:39,代码来源:DataToArrayOfDoublesSketchUDAF.java

示例4: GenericUDFTestDOUBLE

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

示例5: init

@Override
public ObjectInspector init(final Mode mode, final ObjectInspector[] parameters) throws HiveException {
  super.init(mode, parameters);
  mode_ = mode;
  if (mode == Mode.PARTIAL1 || mode == Mode.COMPLETE) {
    // input is original data
    keyInspector_ = (PrimitiveObjectInspector) parameters[0];
    numValues_ = 0;
    while (numValues_ + 1 < parameters.length) {
      if (((PrimitiveObjectInspector) parameters[numValues_ + 1]).getPrimitiveCategory()
          != PrimitiveCategory.DOUBLE) {
        break;
      }
      numValues_++;
    }
    valuesInspectors_ = new PrimitiveObjectInspector[numValues_];
    for (int i = 0; i < numValues_; i++) {
      valuesInspectors_[i] = (PrimitiveObjectInspector) parameters[i + 1];
    }
    if (parameters.length > numValues_ + 1) {
      nominalNumEntriesInspector_ = (PrimitiveObjectInspector) parameters[numValues_ + 1];
    }
    if (parameters.length > numValues_ + 2) {
      samplingProbabilityInspector_ = (PrimitiveObjectInspector) parameters[numValues_ + 2];
    }
  } else {
    // input for PARTIAL2 and FINAL is the output from PARTIAL1
    intermediateInspector_ = (StructObjectInspector) parameters[0];
  }

  if (mode == Mode.PARTIAL1 || mode == Mode.PARTIAL2) {
    // intermediate results need to include the the nominal number of entries and number of values
    return ObjectInspectorFactory.getStandardStructObjectInspector(
      Arrays.asList(NOMINAL_NUM_ENTRIES_FIELD, NUM_VALUES_FIELD, SKETCH_FIELD),
      Arrays.asList(
        PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.INT),
        PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.INT),
        PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY)
      )
    );
  }
  // final results include just the sketch
  return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY);
}
 
开发者ID:DataSketches,项目名称:sketches-hive,代码行数:44,代码来源:DataToArrayOfDoublesSketchUDAF.java


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