本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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 ) );
}
示例13: typeInfo
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; //导入方法依赖的package包/类
static StructTypeInfo typeInfo(StructObjectInspector inspector) {
return (StructTypeInfo) TypeInfoUtils.getTypeInfoFromObjectInspector(inspector);
}
示例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));
}