List of usage examples for org.apache.hadoop.io FloatWritable get
public float get()
From source file:org.apache.mahout.cf.taste.hadoop.SlopeOneDiffsToAveragesReducer.java
License:Apache License
@Override protected void reduce(ItemItemWritable key, Iterable<FloatWritable> values, Context context) throws IOException, InterruptedException { int count = 0; double total = 0.0; for (FloatWritable value : values) { total += value.get(); count++;//from w w w . j a v a 2 s . c o m } context.write(key, new FloatWritable((float) (total / count))); }
From source file:org.goldenorb.io.checkpoint.CheckPointDataTest.java
License:Apache License
/** * Tests the CheckPointDataInput class by reading several different types of Writables from the checkpoint. * Asserts that Writables that were written in are of the same value and type when reading in from HDFS. * //from w ww.j a va 2 s. c o m * @throws Exception */ @Test public void testCheckpointInput() throws Exception { int superStep = 0; int partition = 0; OrbConfiguration orbConf = new OrbConfiguration(); orbConf.set("fs.default.name", "hdfs://localhost:" + cluster.getNameNodePort()); orbConf.setJobNumber("0"); orbConf.setFileOutputPath("test"); CheckPointDataInput checkpointInput = new CheckPointDataInput(orbConf, superStep, partition); // Data is read on a FIFO basis IntWritable intInput = new IntWritable(); intInput.readFields(checkpointInput); LongWritable longInput = new LongWritable(); longInput.readFields(checkpointInput); Text textInput = new Text(); textInput.readFields(checkpointInput); FloatWritable floatInput = new FloatWritable(); floatInput.readFields(checkpointInput); checkpointInput.close(); assertThat(checkpointInput, notNullValue()); assertEquals(intInput.get(), 4); assertEquals(longInput.get(), 9223372036854775807L); assertEquals(textInput.toString(), "test"); assertTrue(floatInput.get() == 3.14159F); }
From source file:org.openflamingo.mapreduce.aggregator.FloatMaxAggregator.java
License:Apache License
@Override public void aggregate(FloatWritable value) { float val = value.get(); if (val > max) { max = val; }/*from w w w .j a va 2 s . c o m*/ }
From source file:org.openflamingo.mapreduce.aggregator.FloatMaxAggregator.java
License:Apache License
@Override public void setAggregatedValue(FloatWritable value) { max = value.get(); }
From source file:org.openflamingo.mapreduce.aggregator.FloatMinAggregator.java
License:Apache License
@Override public void aggregate(FloatWritable value) { float val = value.get(); if (val < min) { min = val; }/*from w w w . j a va2 s . c om*/ }
From source file:org.openflamingo.mapreduce.aggregator.FloatMinAggregator.java
License:Apache License
@Override public void setAggregatedValue(FloatWritable value) { min = value.get(); }
From source file:org.openflamingo.mapreduce.aggregator.FloatOverwriteAggregator.java
License:Apache License
@Override public void aggregate(FloatWritable value) { result = value.get(); }
From source file:org.openflamingo.mapreduce.aggregator.FloatOverwriteAggregator.java
License:Apache License
@Override public void setAggregatedValue(FloatWritable value) { result = value.get(); }
From source file:org.openflamingo.mapreduce.aggregator.FloatProductAggregator.java
License:Apache License
@Override public void aggregate(FloatWritable value) { product *= value.get(); }
From source file:org.openflamingo.mapreduce.aggregator.FloatProductAggregator.java
License:Apache License
@Override public void setAggregatedValue(FloatWritable value) { product = value.get(); }