Search in sources :

Example 11 with DoubleWritable

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);
}
Also used : StandardListObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.StandardListObjectInspector) 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) DeferredObject(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject) DoubleWritable(org.apache.hadoop.io.DoubleWritable) PrimitiveObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector) ByteWritable(org.apache.hadoop.hive.serde2.io.ByteWritable) Test(org.junit.Test)

Example 12 with DoubleWritable

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);
    }
}
Also used : DeferredJavaObject(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject) DeferredObject(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject) DoubleWritable(org.apache.hadoop.io.DoubleWritable) TimestampWritableV2(org.apache.hadoop.hive.serde2.io.TimestampWritableV2)

Example 13 with DoubleWritable

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);
}
Also used : DoubleWritable(org.apache.hadoop.io.DoubleWritable)

Example 14 with DoubleWritable

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);
}
Also used : DoubleMessage(org.goldenorb.types.message.DoubleMessage) DoubleWritable(org.apache.hadoop.io.DoubleWritable) Test(org.junit.Test)

Example 15 with DoubleWritable

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);
}
Also used : DoubleWritable(org.apache.hadoop.io.DoubleWritable) Test(org.junit.Test)

Aggregations

DoubleWritable (org.apache.hadoop.io.DoubleWritable)38 IntWritable (org.apache.hadoop.io.IntWritable)20 Test (org.junit.Test)19 Path (org.apache.hadoop.fs.Path)12 BooleanWritable (org.apache.hadoop.io.BooleanWritable)12 LongWritable (org.apache.hadoop.io.LongWritable)12 BytesWritable (org.apache.hadoop.io.BytesWritable)11 FloatWritable (org.apache.hadoop.io.FloatWritable)11 FileSystem (org.apache.hadoop.fs.FileSystem)10 Writable (org.apache.hadoop.io.Writable)10 Configuration (org.apache.hadoop.conf.Configuration)9 Text (org.apache.hadoop.io.Text)8 HiveDecimalWritable (org.apache.hadoop.hive.serde2.io.HiveDecimalWritable)7 ByteWritable (org.apache.hadoop.io.ByteWritable)7 NullWritable (org.apache.hadoop.io.NullWritable)6 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 SequenceFile (org.apache.hadoop.io.SequenceFile)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4