use of org.apache.hadoop.io.DoubleWritable in project hive by apache.
the class TestGenericUDFNullif method testConversionInSameGroup.
@Test
public void testConversionInSameGroup() throws HiveException {
GenericUDFNullif udf = new GenericUDFNullif();
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableDoubleObjectInspector, PrimitiveObjectInspectorFactory.writableByteObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(new DoubleWritable(4.0)), new DeferredJavaObject(new ByteWritable((byte) 4)) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
}
use of org.apache.hadoop.io.DoubleWritable in project hive by apache.
the class TestGenericUDFMonthsBetween method runTestTs.
protected void runTestTs(String ts1, String ts2, Double expDiff, GenericUDFMonthsBetween udf) throws HiveException {
TimestampWritableV2 tsWr1 = ts1 == null ? null : new TimestampWritableV2(Timestamp.valueOf(ts1));
TimestampWritableV2 tsWr2 = ts2 == null ? null : new TimestampWritableV2(Timestamp.valueOf(ts2));
DeferredJavaObject valueObj1 = new DeferredJavaObject(tsWr1);
DeferredJavaObject valueObj2 = new DeferredJavaObject(tsWr2);
DeferredObject[] args = new DeferredObject[] { valueObj1, valueObj2 };
DoubleWritable output = (DoubleWritable) udf.evaluate(args);
if (expDiff == null) {
assertNull("months_between() test for NULL TIMESTAMP failed", output);
} else {
assertNotNull("months_between() test for NOT NULL TIMESTAMP failed", output);
assertEquals("months_between() test for TIMESTAMP failed", expDiff, output.get(), 0.00000001D);
}
}
use of org.apache.hadoop.io.DoubleWritable in project shifu by ShifuML.
the class FeatureImportanceReducer method reduce.
@Override
protected void reduce(IntWritable key, Iterable<DoubleWritable> values, Context context) throws IOException, InterruptedException {
double sum = 0d;
for (DoubleWritable dw : values) {
sum += dw.get();
}
this.variableStatsMap.put(key.get(), sum);
}
use of org.apache.hadoop.io.DoubleWritable in project goldenorb by jzachr.
the class SampleDoubleMessageTest method testRPC.
@Test
public void testRPC() {
DoubleMessage dm1 = client.sendAndReceiveMessage(dm0, DESTINATION_VALUE, new DoubleWritable(MESSAGE_VALUE));
assertTrue(dm0.get() == client.getMessage().get());
assertEquals(dm0.getDestinationVertex(), client.getMessage().getDestinationVertex());
assertEquals(dm1.getDestinationVertex(), DESTINATION_VALUE);
assertTrue(((DoubleWritable) dm1.getMessageValue()).get() == MESSAGE_VALUE);
}
use of org.apache.hadoop.io.DoubleWritable in project crunch by cloudera.
the class WritablesTest method testDoubles.
@Test
public void testDoubles() throws Exception {
double j = 55.5d;
DoubleWritable w = new DoubleWritable(j);
testInputOutputFn(Writables.doubles(), j, w);
}
Aggregations