use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfo in project hive by apache.
the class TestStreamingSum method sumHiveDecimal.
public void sumHiveDecimal(Iterator<HiveDecimal> inVals, int inSz, int numPreceding, int numFollowing, Iterator<HiveDecimal> outVals) throws HiveException {
GenericUDAFSum fnR = new GenericUDAFSum();
TypeInfo[] inputTypes = { TypeInfoFactory.decimalTypeInfo };
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector };
HiveDecimalWritable[] in = new HiveDecimalWritable[1];
in[0] = new HiveDecimalWritable();
_agg(fnR, inputTypes, inVals, TypeHandler.HiveDecimalHandler, in, inputOIs, inSz, numPreceding, numFollowing, outVals);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfo in project hive by apache.
the class TestStreamingSum method sumDouble.
public void sumDouble(Iterator<Double> inVals, int inSz, int numPreceding, int numFollowing, Iterator<Double> outVals) throws HiveException {
GenericUDAFSum fnR = new GenericUDAFSum();
TypeInfo[] inputTypes = { TypeInfoFactory.doubleTypeInfo };
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableDoubleObjectInspector };
DoubleWritable[] in = new DoubleWritable[1];
in[0] = new DoubleWritable();
_agg(fnR, inputTypes, inVals, TypeHandler.DoubleHandler, in, inputOIs, inSz, numPreceding, numFollowing, outVals);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfo in project hive by apache.
the class WritableConstantHiveDecimalObjectInspector method getWritableConstantValue.
@Override
public HiveDecimalWritable getWritableConstantValue() {
// We need to enforce precision/scale here.
DecimalTypeInfo decTypeInfo = (DecimalTypeInfo) typeInfo;
HiveDecimalWritable result = new HiveDecimalWritable(value);
result.mutateEnforcePrecisionScale(decTypeInfo.precision(), decTypeInfo.scale());
if (!result.isSet()) {
return null;
}
return result;
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfo in project hive by apache.
the class WritableHiveCharObjectInspector method copyObject.
public Object copyObject(Object o) {
if (o == null) {
return null;
}
if (o instanceof Text) {
String str = ((Text) o).toString();
HiveCharWritable hcw = new HiveCharWritable();
hcw.set(str, ((CharTypeInfo) typeInfo).getLength());
return hcw;
}
HiveCharWritable writable = (HiveCharWritable) o;
if (doesWritableMatchTypeParams((HiveCharWritable) o)) {
return new HiveCharWritable(writable);
}
return getWritableWithParams(writable);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfo in project haivvreo by jghoman.
the class AvroObjectInspectorGenerator method createObjectInspectorWorker.
private ObjectInspector createObjectInspectorWorker(TypeInfo ti) throws SerDeException {
// at deserialization and the object inspector will never see the actual union.
if (!supportedCategories(ti))
throw new HaivvreoException("Don't yet support this type: " + ti);
ObjectInspector result;
switch(ti.getCategory()) {
case PRIMITIVE:
PrimitiveTypeInfo pti = (PrimitiveTypeInfo) ti;
result = PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(pti.getPrimitiveCategory());
break;
case STRUCT:
StructTypeInfo sti = (StructTypeInfo) ti;
ArrayList<ObjectInspector> ois = new ArrayList<ObjectInspector>(sti.getAllStructFieldTypeInfos().size());
for (TypeInfo typeInfo : sti.getAllStructFieldTypeInfos()) {
ois.add(createObjectInspectorWorker(typeInfo));
}
result = ObjectInspectorFactory.getStandardStructObjectInspector(sti.getAllStructFieldNames(), ois);
break;
case MAP:
MapTypeInfo mti = (MapTypeInfo) ti;
result = ObjectInspectorFactory.getStandardMapObjectInspector(PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(PrimitiveObjectInspector.PrimitiveCategory.STRING), createObjectInspectorWorker(mti.getMapValueTypeInfo()));
break;
case LIST:
ListTypeInfo ati = (ListTypeInfo) ti;
result = ObjectInspectorFactory.getStandardListObjectInspector(createObjectInspectorWorker(ati.getListElementTypeInfo()));
break;
case UNION:
UnionTypeInfo uti = (UnionTypeInfo) ti;
List<TypeInfo> allUnionObjectTypeInfos = uti.getAllUnionObjectTypeInfos();
List<ObjectInspector> unionObjectInspectors = new ArrayList<ObjectInspector>(allUnionObjectTypeInfos.size());
for (TypeInfo typeInfo : allUnionObjectTypeInfos) {
unionObjectInspectors.add(createObjectInspectorWorker(typeInfo));
}
result = ObjectInspectorFactory.getStandardUnionObjectInspector(unionObjectInspectors);
break;
default:
throw new HaivvreoException("No Hive categories matched: " + ti);
}
return result;
}
Aggregations