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


Java PrimitiveCategory.DECIMAL属性代码示例

本文整理汇总了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;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:27,代码来源:HiveUtilities.java

示例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;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:39,代码来源:HiveFieldConverter.java

示例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();
  }
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:9,代码来源:GenericUDAFBinarySetFunctions.java

示例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;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:27,代码来源:HiveAbstractReader.java

示例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;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:31,代码来源:HiveFieldConverter.java

示例6: GenericUDFTestDECIMAL

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


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