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


Java TypeInfoUtils.getTypeInfoFromObjectInspector方法代码示例

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


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

示例1: getConstStringArray

import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; //导入方法依赖的package包/类
@Nullable
public static String[] getConstStringArray(@Nonnull final ObjectInspector oi)
        throws UDFArgumentException {
    if (!ObjectInspectorUtils.isConstantObjectInspector(oi)) {
        throw new UDFArgumentException("argument must be a constant value: "
                + TypeInfoUtils.getTypeInfoFromObjectInspector(oi));
    }
    ConstantObjectInspector constOI = (ConstantObjectInspector) oi;
    if (constOI.getCategory() != Category.LIST) {
        throw new UDFArgumentException("argument must be an array: "
                + TypeInfoUtils.getTypeInfoFromObjectInspector(oi));
    }
    final List<?> lst = (List<?>) constOI.getWritableConstantValue();
    if (lst == null) {
        return null;
    }
    final int size = lst.size();
    final String[] ary = new String[size];
    for (int i = 0; i < size; i++) {
        Object o = lst.get(i);
        if (o != null) {
            ary[i] = o.toString();
        }
    }
    return ary;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:27,代码来源:HiveUtils.java

示例2: initialize

import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
  if (arguments.length < 2) {
    throw new UDFArgumentLengthException(getFuncName() + " requires at least 2 arguments, got "
      + arguments.length);
  }
  if (arguments[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
    throw new UDFArgumentException(getFuncName() + " only takes primitive types, got "
      + arguments[0].getTypeName());
  }

  argumentOIs = arguments;
  converters = new Converter[arguments.length];

  TypeInfo commonInfo = TypeInfoUtils.getTypeInfoFromObjectInspector(arguments[0]);

  for (int i = 1; i < arguments.length; i++) {
    PrimitiveTypeInfo currInfo = (PrimitiveTypeInfo) TypeInfoUtils.getTypeInfoFromObjectInspector(arguments[i]);

    commonInfo = FunctionRegistry.getCommonClassForComparison(
      commonInfo, currInfo);
  }

  resultOI = TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(
    (commonInfo == null) ?
      TypeInfoFactory.doubleTypeInfo : commonInfo);

  for (int i = 0; i < arguments.length; i++) {
    converters[i] = ObjectInspectorConverters.getConverter(arguments[i], resultOI);
  }

  return resultOI;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:34,代码来源:GenericUDFBaseNwayCompare.java

示例3: getConstValue

import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Nullable
public static <T extends Writable> T getConstValue(@Nonnull final ObjectInspector oi)
        throws UDFArgumentException {
    if (!ObjectInspectorUtils.isConstantObjectInspector(oi)) {
        throw new UDFArgumentException("argument must be a constant value: "
                + TypeInfoUtils.getTypeInfoFromObjectInspector(oi));
    }
    ConstantObjectInspector constOI = (ConstantObjectInspector) oi;
    Object v = constOI.getWritableConstantValue();
    return (T) v;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:13,代码来源:HiveUtils.java

示例4: getConstDoubleArray

import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; //导入方法依赖的package包/类
@Nullable
public static double[] getConstDoubleArray(@Nonnull final ObjectInspector oi)
        throws UDFArgumentException {
    if (!ObjectInspectorUtils.isConstantObjectInspector(oi)) {
        throw new UDFArgumentException("argument must be a constant value: "
                + TypeInfoUtils.getTypeInfoFromObjectInspector(oi));
    }
    ConstantObjectInspector constOI = (ConstantObjectInspector) oi;
    if (constOI.getCategory() != Category.LIST) {
        throw new UDFArgumentException("argument must be an array: "
                + TypeInfoUtils.getTypeInfoFromObjectInspector(oi));
    }
    StandardConstantListObjectInspector listOI = (StandardConstantListObjectInspector) constOI;
    PrimitiveObjectInspector elemOI = HiveUtils.asDoubleCompatibleOI(listOI.getListElementObjectInspector());

    final List<?> lst = listOI.getWritableConstantValue();
    if (lst == null) {
        return null;
    }
    final int size = lst.size();
    final double[] ary = new double[size];
    for (int i = 0; i < size; i++) {
        Object o = lst.get(i);
        if (o == null) {
            ary[i] = Double.NaN;
        } else {
            ary[i] = PrimitiveObjectInspectorUtils.getDouble(o, elemOI);
        }
    }
    return ary;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:32,代码来源:HiveUtils.java

示例5: getConstString

import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; //导入方法依赖的package包/类
public static String getConstString(@Nonnull final ObjectInspector oi)
        throws UDFArgumentException {
    if (!isStringOI(oi)) {
        throw new UDFArgumentException("argument must be a Text value: "
                + TypeInfoUtils.getTypeInfoFromObjectInspector(oi));
    }
    Text v = getConstValue(oi);
    return v == null ? null : v.toString();
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:10,代码来源:HiveUtils.java

示例6: getConstBoolean

import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; //导入方法依赖的package包/类
public static boolean getConstBoolean(@Nonnull final ObjectInspector oi)
        throws UDFArgumentException {
    if (!isBooleanOI(oi)) {
        throw new UDFArgumentException("argument must be a Boolean value: "
                + TypeInfoUtils.getTypeInfoFromObjectInspector(oi));
    }
    BooleanWritable v = getConstValue(oi);
    return v.get();
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:10,代码来源:HiveUtils.java

示例7: getConstInt

import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; //导入方法依赖的package包/类
public static int getConstInt(@Nonnull final ObjectInspector oi) throws UDFArgumentException {
    if (!isIntOI(oi)) {
        throw new UDFArgumentException("argument must be a Int value: "
                + TypeInfoUtils.getTypeInfoFromObjectInspector(oi));
    }
    IntWritable v = getConstValue(oi);
    return v.get();
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:9,代码来源:HiveUtils.java

示例8: getConstLong

import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; //导入方法依赖的package包/类
public static long getConstLong(@Nonnull final ObjectInspector oi) throws UDFArgumentException {
    if (!isBigIntOI(oi)) {
        throw new UDFArgumentException("argument must be a BigInt value: "
                + TypeInfoUtils.getTypeInfoFromObjectInspector(oi));
    }
    LongWritable v = getConstValue(oi);
    return v.get();
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:9,代码来源:HiveUtils.java

示例9: asConstantObjectInspector

import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; //导入方法依赖的package包/类
@Nonnull
public static ConstantObjectInspector asConstantObjectInspector(
        @Nonnull final ObjectInspector oi) throws UDFArgumentException {
    if (!ObjectInspectorUtils.isConstantObjectInspector(oi)) {
        throw new UDFArgumentException("argument must be a constant value: "
                + TypeInfoUtils.getTypeInfoFromObjectInspector(oi));
    }
    return (ConstantObjectInspector) oi;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:10,代码来源:HiveUtils.java

示例10: asPrimitiveObjectInspector

import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; //导入方法依赖的package包/类
@Nonnull
public static PrimitiveObjectInspector asPrimitiveObjectInspector(
        @Nonnull final ObjectInspector oi) throws UDFArgumentException {
    if (oi.getCategory() != Category.PRIMITIVE) {
        throw new UDFArgumentException("Expecting PrimitiveObjectInspector: "
                + TypeInfoUtils.getTypeInfoFromObjectInspector(oi));
    }
    return (PrimitiveObjectInspector) oi;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:10,代码来源:HiveUtils.java

示例11: getTypeInfoFromLocation

import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; //导入方法依赖的package包/类
private TypeInfo getTypeInfoFromLocation(String location, Job job) throws IOException {
    FileSystem fs = FileSystem.get(job.getConfiguration());
    Path path = getFirstFile(location, fs);
    if (path == null) {
        log.info("Cannot find any ORC files from " + location +
                ". Probably multiple load store in script.");
        return null;
    }
    Reader reader = OrcFile.createReader(fs, path);
    ObjectInspector oip = (ObjectInspector)reader.getObjectInspector();
    return TypeInfoUtils.getTypeInfoFromObjectInspector(oip);
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:13,代码来源:OrcStorage.java

示例12: getOrcTypeInfo

import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; //导入方法依赖的package包/类
public static TypeInfo getOrcTypeInfo( final Configuration config , final String target ) throws IOException{
  return TypeInfoUtils.getTypeInfoFromObjectInspector( getOrcObjectInspector( config , target ) );
}
 
开发者ID:yahoojapan,项目名称:dataplatform-schema-lib,代码行数:4,代码来源:OrcSchemaUtil.java

示例13: typeInfo

import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; //导入方法依赖的package包/类
static StructTypeInfo typeInfo(StructObjectInspector inspector) {
    return (StructTypeInfo) TypeInfoUtils.getTypeInfoFromObjectInspector(inspector);
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:4,代码来源:HiveUtils.java

示例14: evaluate

import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; //导入方法依赖的package包/类
@Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
  List<?> inputs = (List<?>)
    ObjectInspectorUtils.copyToStandardObject(arguments[0].get(), listOI);

  if (inputs == null) {
    return null;
  }

  if (evaluator == null) {
    Text functionName = 
      (Text)ObjectInspectorUtils.copyToStandardObject(arguments[1].get(), stringOI);

    if (functionName == null) {
      throw new HiveException("Function name cannot be null.");
    }

    GenericUDAFResolver resolver =
      FunctionRegistry.getGenericUDAFResolver(functionName.toString());
    if (resolver == null) {
      throw new HiveException("Could not find function with name " + 
                              functionName.toString());
    }
    
    ObjectInspector[] objectInspectorArray = new ObjectInspector[1];
    objectInspectorArray[0] = elementOI;
   
    TypeInfo[] typeInfoArray = new TypeInfo[1];
    typeInfoArray[0] = 
      TypeInfoUtils.getTypeInfoFromObjectInspector(elementOI);
    
    evaluator = resolver.getEvaluator(typeInfoArray);
    converter = ObjectInspectorConverters.getConverter(
      evaluator.init(GenericUDAFEvaluator.Mode.COMPLETE, objectInspectorArray),
      elementOI);
    buffer = evaluator.getNewAggregationBuffer();
  } 

  evaluator.reset(buffer);

  for (Object input : inputs) {
    inputArray[0] = input;
    evaluator.iterate(buffer, inputArray);
  }

  return converter.convert(evaluator.terminate(buffer));
}
 
开发者ID:brndnmtthws,项目名称:facebook-hive-udfs,代码行数:48,代码来源:UDFArrayAggregate.java


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