Search in sources :

Example 11 with DoubleWritable

use of org.apache.hadoop.hive.serde2.io.DoubleWritable 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);
}
Also used : ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) DoubleWritable(org.apache.hadoop.hive.serde2.io.DoubleWritable) TypeInfo(org.apache.hadoop.hive.serde2.typeinfo.TypeInfo) GenericUDAFSum(org.apache.hadoop.hive.ql.udf.generic.GenericUDAFSum)

Example 12 with DoubleWritable

use of org.apache.hadoop.hive.serde2.io.DoubleWritable in project hive by apache.

the class TestGenericUDFAbs method testDouble.

public void testDouble() throws HiveException {
    GenericUDFAbs udf = new GenericUDFAbs();
    ObjectInspector valueOI = PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
    ObjectInspector[] arguments = { valueOI };
    udf.initialize(arguments);
    DeferredObject valueObj = new DeferredJavaObject(new DoubleWritable(107.78));
    DeferredObject[] args = { valueObj };
    DoubleWritable output = (DoubleWritable) udf.evaluate(args);
    assertEquals("abs() test for Double failed ", 107.78, output.get());
    valueObj = new DeferredJavaObject(new DoubleWritable(-107.78));
    args[0] = valueObj;
    output = (DoubleWritable) udf.evaluate(args);
    assertEquals("abs() test for Double failed ", 107.78, output.get());
}
Also used : PrimitiveObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector) ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) DeferredJavaObject(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject) GenericUDFAbs(org.apache.hadoop.hive.ql.udf.generic.GenericUDFAbs) DeferredObject(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject) DoubleWritable(org.apache.hadoop.hive.serde2.io.DoubleWritable)

Example 13 with DoubleWritable

use of org.apache.hadoop.hive.serde2.io.DoubleWritable in project hive by apache.

the class TestUDFMath method testAcos.

@Test
public void testAcos() throws HiveException {
    UDFAcos udf = new UDFAcos();
    input = createDecimal("0.716");
    DoubleWritable res = udf.evaluate(input);
    Assert.assertEquals(0.7727408115633954, res.get(), 0.000001);
}
Also used : DoubleWritable(org.apache.hadoop.hive.serde2.io.DoubleWritable) Test(org.junit.Test)

Example 14 with DoubleWritable

use of org.apache.hadoop.hive.serde2.io.DoubleWritable in project hive by apache.

the class TestUDFMath method testLog10.

@Test
public void testLog10() throws HiveException {
    UDFLog10 udf = new UDFLog10();
    input = createDecimal("100.0");
    DoubleWritable res = udf.evaluate(input);
    Assert.assertEquals(2.0, res.get(), 0.000001);
}
Also used : DoubleWritable(org.apache.hadoop.hive.serde2.io.DoubleWritable) Test(org.junit.Test)

Example 15 with DoubleWritable

use of org.apache.hadoop.hive.serde2.io.DoubleWritable in project hive by apache.

the class TestUDFMath method testSqrt.

@Test
public void testSqrt() throws HiveException {
    UDFSqrt udf = new UDFSqrt();
    input = createDecimal("49.0");
    DoubleWritable res = udf.evaluate(input);
    Assert.assertEquals(7.0, res.get(), 0.000001);
}
Also used : DoubleWritable(org.apache.hadoop.hive.serde2.io.DoubleWritable) Test(org.junit.Test)

Aggregations

DoubleWritable (org.apache.hadoop.hive.serde2.io.DoubleWritable)113 Test (org.junit.Test)61 IntWritable (org.apache.hadoop.io.IntWritable)50 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)49 LongWritable (org.apache.hadoop.io.LongWritable)48 DeferredJavaObject (org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject)42 DeferredObject (org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject)42 Text (org.apache.hadoop.io.Text)42 PrimitiveObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector)40 ShortWritable (org.apache.hadoop.hive.serde2.io.ShortWritable)38 ByteWritable (org.apache.hadoop.hive.serde2.io.ByteWritable)37 FloatWritable (org.apache.hadoop.io.FloatWritable)34 BooleanWritable (org.apache.hadoop.io.BooleanWritable)28 HiveDecimalWritable (org.apache.hadoop.hive.serde2.io.HiveDecimalWritable)24 BytesWritable (org.apache.hadoop.io.BytesWritable)21 ArrayList (java.util.ArrayList)19 HiveVarcharWritable (org.apache.hadoop.hive.serde2.io.HiveVarcharWritable)16 TimestampWritable (org.apache.hadoop.hive.serde2.io.TimestampWritable)15 HiveVarchar (org.apache.hadoop.hive.common.type.HiveVarchar)12 DateWritable (org.apache.hadoop.hive.serde2.io.DateWritable)12