use of org.apache.hadoop.io.DoubleWritable in project hive by apache.
the class TestETypeConverter method testGetFloatConverterForDouble.
@Test
public void testGetFloatConverterForDouble() throws Exception {
MyConverterParent converterParent = new MyConverterParent();
PrimitiveType primitiveType = Types.optional(PrimitiveTypeName.FLOAT).named("value");
PrimitiveConverter converter = ETypeConverter.getNewConverter(primitiveType, 1, converterParent, createHiveTypeInfo("double"));
((PrimitiveConverter) converter).addFloat(3276f);
Writable writable = converterParent.getValue();
DoubleWritable doubleWritable = (DoubleWritable) writable;
assertEquals(3276d, doubleWritable.get(), 0);
}
use of org.apache.hadoop.io.DoubleWritable in project hive by apache.
the class TestGenericUDFMonthsBetween method runTestDt.
protected void runTestDt(String dt1, String dt2, Double expDiff, GenericUDFMonthsBetween udf) throws HiveException {
DateWritableV2 dtWr1 = dt1 == null ? null : new DateWritableV2(Date.valueOf(dt1));
DateWritableV2 dtWr2 = dt2 == null ? null : new DateWritableV2(Date.valueOf(dt2));
DeferredJavaObject valueObj1 = new DeferredJavaObject(dtWr1);
DeferredJavaObject valueObj2 = new DeferredJavaObject(dtWr2);
DeferredObject[] args = new DeferredObject[] { valueObj1, valueObj2 };
DoubleWritable output = (DoubleWritable) udf.evaluate(args);
if (expDiff == null) {
assertNull("months_between() test for NULL DATE failed", output);
} else {
assertNotNull("months_between() test for NOT NULL DATE failed", output);
assertEquals("months_between() test for DATE failed", expDiff, output.get(), 0.00000001D);
}
}
use of org.apache.hadoop.io.DoubleWritable in project hive by apache.
the class TestGenericUDFMonthsBetween method runTestStr.
protected void runTestStr(String date1, String date2, Double expDiff, GenericUDFMonthsBetween udf) throws HiveException {
DeferredJavaObject valueObj1 = new DeferredJavaObject(date1 == null ? null : new Text(date1));
DeferredJavaObject valueObj2 = new DeferredJavaObject(date2 == null ? null : new Text(date2));
DeferredObject[] args = new DeferredObject[] { valueObj1, valueObj2 };
DoubleWritable output = (DoubleWritable) udf.evaluate(args);
if (expDiff == null) {
assertNull("months_between() test for NULL STRING failed", output);
} else {
assertNotNull("months_between() test for NOT NULL STRING failed", output);
assertEquals("months_between() test for STRING failed", expDiff, output.get(), 0.00000001D);
}
}
Aggregations