List of usage examples for org.apache.hadoop.io FloatWritable get
public float get()
From source file:org.openflamingo.mapreduce.aggregator.FloatSumAggregator.java
License:Apache License
@Override public void aggregate(FloatWritable value) { sum += value.get(); }
From source file:org.openflamingo.mapreduce.aggregator.FloatSumAggregator.java
License:Apache License
@Override public void setAggregatedValue(FloatWritable value) { sum = value.get(); }
From source file:org.shadowmask.engine.hive.udf.UDFHiding.java
License:Apache License
/** * Float version/* w ww . j av a 2 s . co m*/ */ public FloatWritable evaluate(FloatWritable data, FloatWritable value) { if (value == null) { return null; } FloatWritable result = new FloatWritable(value.get()); return result; }
From source file:org.shadowmask.engine.hive.udf.UDFHidingTest.java
License:Apache License
@Test public void testUDFHiding() { UDFHiding udfHiding = new UDFHiding(); ByteWritable dataByte = new ByteWritable((byte) 34); ByteWritable valueByte = new ByteWritable((byte) 46); ByteWritable result1 = udfHiding.evaluate(dataByte, valueByte); assertEquals(valueByte.get(), result1.get()); DoubleWritable dataDouble = new DoubleWritable(34.45); DoubleWritable valueDouble = new DoubleWritable(4.6); DoubleWritable result2 = udfHiding.evaluate(dataDouble, valueDouble); assertEquals(valueDouble.get(), result2.get(), Double.MIN_VALUE); FloatWritable dataFloat = new FloatWritable(34.45f); FloatWritable valueFloat = new FloatWritable(4.6f); FloatWritable result3 = udfHiding.evaluate(dataFloat, valueFloat); assertEquals(valueFloat.get(), result3.get(), Float.MIN_VALUE); IntWritable dataInt = new IntWritable(33456); IntWritable valueInt = new IntWritable(-4546); IntWritable result4 = udfHiding.evaluate(dataInt, valueInt); assertEquals(valueInt.get(), result4.get()); LongWritable dataLong = new LongWritable(334563L); LongWritable valueLong = new LongWritable(-45465555L); LongWritable result5 = udfHiding.evaluate(dataLong, valueLong); assertEquals(valueLong.get(), result5.get()); ShortWritable dataShort = new ShortWritable((short) 33); ShortWritable valueShort = new ShortWritable((short) -4548); ShortWritable result6 = udfHiding.evaluate(dataShort, valueShort); assertEquals(valueShort.get(), result6.get()); Text dataText = new Text("hello"); Text valueText = new Text("intel"); Text result7 = udfHiding.evaluate(dataText, valueText); assertEquals(valueText.toString(), result7.toString()); }
From source file:org.shaf.core.util.IOUtilsTest.java
License:Apache License
/** * Test writing of {@code float} value./* w ww .j av a2 s. com*/ */ @Test public void testWriteFloat() { byte[] buf = null; float value = 123.456f; try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(baos);) { IOUtils.writeObject(value, out); buf = baos.toByteArray(); } catch (IOException exc) { fail(exc.getMessage()); } try (ByteArrayInputStream bais = new ByteArrayInputStream(buf); DataInputStream in = new DataInputStream(bais);) { FloatWritable probe = new FloatWritable(); probe.readFields(in); assertEquals(value, probe.get(), 0.0001); } catch (IOException exc) { fail(exc.getMessage()); } }
From source file:tlfetl.card.TLFDWHValue.java
@Override public void readFields(DataInput di) throws IOException { FloatWritable writableAmount = new FloatWritable(); IntWritable writableCount = new IntWritable(); writableAmount.readFields(di);//ww w .j a va 2s . co m writableCount.readFields(di); amount = writableAmount.get(); count = writableCount.get(); }