use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfo in project hive by apache.
the class TestStreamingAvg method avgHiveDecimal.
public void avgHiveDecimal(Iterator<HiveDecimal> inVals, int inSz, int numPreceding, int numFollowing, Iterator<HiveDecimal> outVals) throws HiveException {
GenericUDAFAverage fnR = new GenericUDAFAverage();
TypeInfo[] inputTypes = { TypeInfoFactory.decimalTypeInfo };
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector };
HiveDecimalWritable[] in = new HiveDecimalWritable[1];
in[0] = new HiveDecimalWritable();
TestStreamingSum._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 TestStreamingAvg method avgDouble.
public void avgDouble(Iterator<Double> inVals, int inSz, int numPreceding, int numFollowing, Iterator<Double> outVals) throws HiveException {
GenericUDAFAverage fnR = new GenericUDAFAverage();
TypeInfo[] inputTypes = { TypeInfoFactory.doubleTypeInfo };
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableDoubleObjectInspector };
DoubleWritable[] in = new DoubleWritable[1];
in[0] = new DoubleWritable();
TestStreamingSum._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 TestGenericUDAFCorrelation method testCorr.
public void testCorr() throws HiveException {
GenericUDAFCorrelation corr = new GenericUDAFCorrelation();
GenericUDAFEvaluator eval1 = corr.getEvaluator(new TypeInfo[] { TypeInfoFactory.doubleTypeInfo, TypeInfoFactory.doubleTypeInfo });
GenericUDAFEvaluator eval2 = corr.getEvaluator(new TypeInfo[] { TypeInfoFactory.doubleTypeInfo, TypeInfoFactory.doubleTypeInfo });
ObjectInspector poi1 = eval1.init(GenericUDAFEvaluator.Mode.PARTIAL1, new ObjectInspector[] { PrimitiveObjectInspectorFactory.javaDoubleObjectInspector, PrimitiveObjectInspectorFactory.javaDoubleObjectInspector });
ObjectInspector poi2 = eval2.init(GenericUDAFEvaluator.Mode.PARTIAL1, new ObjectInspector[] { PrimitiveObjectInspectorFactory.javaDoubleObjectInspector, PrimitiveObjectInspectorFactory.javaDoubleObjectInspector });
GenericUDAFEvaluator.AggregationBuffer buffer1 = eval1.getNewAggregationBuffer();
eval1.iterate(buffer1, new Object[] { 100d, 200d });
eval1.iterate(buffer1, new Object[] { 150d, 210d });
eval1.iterate(buffer1, new Object[] { 200d, 220d });
Object object1 = eval1.terminatePartial(buffer1);
GenericUDAFEvaluator.AggregationBuffer buffer2 = eval2.getNewAggregationBuffer();
eval2.iterate(buffer2, new Object[] { 250d, 230d });
eval2.iterate(buffer2, new Object[] { 250d, 240d });
eval2.iterate(buffer2, new Object[] { 300d, 250d });
eval2.iterate(buffer2, new Object[] { 350d, 260d });
Object object2 = eval2.terminatePartial(buffer2);
ObjectInspector coi = eval2.init(GenericUDAFEvaluator.Mode.FINAL, new ObjectInspector[] { poi1 });
GenericUDAFEvaluator.AggregationBuffer buffer3 = eval2.getNewAggregationBuffer();
eval2.merge(buffer3, object1);
eval2.merge(buffer3, object2);
Object result = eval2.terminate(buffer3);
assertEquals("0.987829161147262", String.valueOf(result));
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfo in project hive by apache.
the class TestStreamingMin method minLong.
public void minLong(Iterator<Long> inVals, int inSz, int numPreceding, int numFollowing, Iterator<Long> outVals) throws HiveException {
GenericUDAFMin fnR = new GenericUDAFMin();
TypeInfo[] inputTypes = { TypeInfoFactory.longTypeInfo };
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableLongObjectInspector };
LongWritable[] in = new LongWritable[1];
in[0] = new LongWritable();
TestStreamingSum._agg(fnR, inputTypes, inVals, TypeHandler.LongHandler, in, inputOIs, inSz, numPreceding, numFollowing, outVals);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfo in project hive by apache.
the class TestStreamingSum method sumLong.
public void sumLong(Iterator<Long> inVals, int inSz, int numPreceding, int numFollowing, Iterator<Long> outVals) throws HiveException {
GenericUDAFSum fnR = new GenericUDAFSum();
TypeInfo[] inputTypes = { TypeInfoFactory.longTypeInfo };
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableLongObjectInspector };
LongWritable[] in = new LongWritable[1];
in[0] = new LongWritable();
_agg(fnR, inputTypes, inVals, TypeHandler.LongHandler, in, inputOIs, inSz, numPreceding, numFollowing, outVals);
}
Aggregations