List of usage examples for org.apache.hadoop.io DoubleWritable DoubleWritable
public DoubleWritable(double value)
From source file:org.apache.giraph.ranking.LinkRank.TrustRankVertexMasterCompute.java
License:Apache License
@Override public void compute() { // add additional 3 steps for normalization. long maxSteps = getContext().getConfiguration().getLong(TrustRankComputation.SUPERSTEP_COUNT, 10) + 3; long superstep = getSuperstep(); if (superstep == maxSteps - 2) { /**/*w w w. ja va 2s .co m*/ * We should have log values of the scores aggregated in SUM_OF_LOGS. * Divide this sum by total number of vertices and aggragate in * AVG_OF_LOGS. */ DoubleWritable logsum = getAggregatedValue(TrustRankComputation.SUM_OF_LOGS); DoubleWritable avg = new DoubleWritable(logsum.get() / getTotalNumVertices()); setAggregatedValue(TrustRankComputation.AVG_OF_LOGS, avg); } else if (superstep == maxSteps) { /** * Calculate standart deviation with deviation sums SUM_OF_DEVS. * Aggregate result to STDEV. */ DoubleWritable devSum = getAggregatedValue(TrustRankComputation.SUM_OF_DEVS); double ratio = devSum.get() / getTotalNumVertices(); DoubleWritable stdev = new DoubleWritable(Math.sqrt(ratio)); setAggregatedValue(TrustRankComputation.STDEV, stdev); } }
From source file:org.apache.giraph.types.ops.DoubleTypeOps.java
License:Apache License
@Override public DoubleWritable createCopy(DoubleWritable from) { return new DoubleWritable(from.get()); }
From source file:org.apache.giraph.writable.kryo.DirectWritableSerializerCopyTest.java
License:Apache License
@Test public void test1() { DoubleWritable value = new DoubleWritable(5.9999); DirectWritableSerializer<DoubleWritable> serializer = new DirectWritableSerializer<>(); Kryo kryo = new Kryo(); DoubleWritable copy = serializer.copy(kryo, value); Assert.assertEquals(value.get(), copy.get(), 0); }
From source file:org.apache.giraph.writable.kryo.DirectWritableSerializerCopyTest.java
License:Apache License
@Test public void test2() { WDoubleArrayList list = new WDoubleArrayList(); list.addW(new DoubleWritable(0.11111111)); list.addW(new DoubleWritable(1000.9)); list.addW(new DoubleWritable(99999999.99999999)); DirectWritableSerializer<WDoubleArrayList> serializer = new DirectWritableSerializer<>(); Kryo kryo = new Kryo(); WDoubleArrayList copy = serializer.copy(kryo, list); DoubleWritable reusable = new DoubleWritable(); copy.getIntoW(0, reusable);//from w w w. ja v a2 s .c o m Assert.assertEquals(0.11111111, reusable.get(), 0); copy.getIntoW(1, reusable); Assert.assertEquals(1000.9, reusable.get(), 0); copy.getIntoW(2, reusable); Assert.assertEquals(99999999.99999999, reusable.get(), 0); }
From source file:org.apache.giraph.writable.tuple.DoubleDoubleWritable.java
License:Apache License
/** * Constructor/*from w ww .ja va2 s .c om*/ * * @param left the left value * @param right the right value */ public DoubleDoubleWritable(double left, double right) { super(new DoubleWritable(left), new DoubleWritable(right)); }
From source file:org.apache.giraph.writable.tuple.IntDoubleWritable.java
License:Apache License
/** * Constructor/*from w w w . j a v a 2 s .com*/ * * @param left the left value * @param right the right value */ public IntDoubleWritable(int left, double right) { super(new IntWritable(left), new DoubleWritable(right)); }
From source file:org.apache.giraph.writable.tuple.LongDoubleWritable.java
License:Apache License
/** * Constructor//from ww w. j a v a 2 s . c o m * * @param left the left value * @param right the right value */ public LongDoubleWritable(long left, double right) { super(new LongWritable(left), new DoubleWritable(right)); }
From source file:org.apache.hama.graph.AbsDiffAggregator.java
License:Apache License
@Override public DoubleWritable getValue() { return new DoubleWritable(absoluteDifference); }
From source file:org.apache.hama.graph.AverageAggregator.java
License:Apache License
@Override public DoubleWritable finalizeAggregation() { return new DoubleWritable(getValue().get() / getTimesAggregated().get()); }
From source file:org.apache.hama.graph.SumAggregator.java
License:Apache License
@Override public DoubleWritable getValue() { return new DoubleWritable(sum); }