Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

A couple of aggregator less... thanks Sebastian.

  • Loading branch information...
commit 2fa8a1b879a464d8e3db84e78edd539c70274e7c 1 parent 11f07dd
@castagna authored
View
8 src/main/java/org/apache/jena/grande/giraph/pagerank/PageRankVertex.java
@@ -40,21 +40,18 @@
private double tolerance;
private Aggregator<?> danglingCurrentAggegator;
private Aggregator<?> pagerankSumAggegator;
- private Aggregator<?> errorPreviousAggegator;
@Override
public void compute(Iterator<DoubleWritable> msgIterator) {
log.debug("{}#{} compute() vertexValue={}", new Object[]{getVertexId(), getSuperstep(), getVertexValue()});
danglingCurrentAggegator = getAggregator("dangling-current");
- @SuppressWarnings("unchecked") Aggregator<DoubleWritable> danglingPreviousAggegator = (Aggregator<DoubleWritable>)getAggregator("dangling-previous");
@SuppressWarnings("unchecked") Aggregator<DoubleWritable> errorCurrentAggegator = (Aggregator<DoubleWritable>)getAggregator("error-current");
- errorPreviousAggegator = getAggregator("error-previous");
pagerankSumAggegator = getAggregator("pagerank-sum");
@SuppressWarnings("unchecked") Aggregator<LongWritable> verticesCountAggregator = (Aggregator<LongWritable>)getAggregator("vertices-count");
long numVertices = verticesCountAggregator.getAggregatedValue().get();
- double danglingNodesContribution = danglingPreviousAggegator.getAggregatedValue().get();
+ double danglingNodesContribution = PageRankVertexWorkerContext.danglingPrevious;
numIterations = getConf().getInt("giraph.pagerank.iterations", DEFAULT_NUM_ITERATIONS);
tolerance = getConf().getFloat("giraph.pagerank.tolerance", DEFAULT_TOLERANCE);
@@ -87,8 +84,7 @@ public void compute(Iterator<DoubleWritable> msgIterator) {
@SuppressWarnings("unchecked")
private void sendMessages() {
- double error = ((Aggregator<DoubleWritable>)errorPreviousAggegator).getAggregatedValue().get();
- if ( ( getSuperstep() - 3 < numIterations ) && ( error > tolerance ) ) {
+ if ( ( getSuperstep() - 3 < numIterations ) && ( PageRankVertexWorkerContext.errorPrevious > tolerance ) ) {
long edges = getNumOutEdges();
if ( edges > 0 ) {
sendMsgToAllEdges ( new DoubleWritable(getVertexValue().get() / edges) );
View
10 src/main/java/org/apache/jena/grande/giraph/pagerank/PageRankVertexWorkerContext.java
@@ -30,18 +30,18 @@
private static final Logger log = LoggerFactory.getLogger(PageRankVertexWorkerContext.class);
+ public static double errorPrevious = Double.MAX_VALUE;
+ public static double danglingPrevious = 0d;
+
@SuppressWarnings("unchecked")
@Override
public void preApplication() throws InstantiationException, IllegalAccessException {
log.debug("preApplication()");
registerAggregator("dangling-current", SumAggregator.class);
- registerAggregator("dangling-previous", SumAggregator.class);
registerAggregator("error-current", SumAggregator.class);
- registerAggregator("error-previous", SumAggregator.class);
registerAggregator("pagerank-sum", SumAggregator.class);
registerAggregator("vertices-count", LongSumAggregator.class);
- ((Aggregator<DoubleWritable>)getAggregator("error-previous")).setAggregatedValue( new DoubleWritable( Double.MAX_VALUE ) );
((Aggregator<DoubleWritable>)getAggregator("error-current")).setAggregatedValue( new DoubleWritable( Double.MAX_VALUE ) );
}
@@ -56,10 +56,10 @@ public void postApplication() {
public void preSuperstep() {
log.debug("preSuperstep()");
if ( getSuperstep() > 2 ) {
- ((Aggregator<DoubleWritable>)getAggregator("error-previous")).setAggregatedValue( new DoubleWritable(((Aggregator<DoubleWritable>)getAggregator("error-current")).getAggregatedValue().get()) );
+ errorPrevious = ((Aggregator<DoubleWritable>)getAggregator("error-current")).getAggregatedValue().get();
((Aggregator<DoubleWritable>)getAggregator("error-current")).setAggregatedValue( new DoubleWritable(0L) );
}
- ((Aggregator<DoubleWritable>)getAggregator("dangling-previous")).setAggregatedValue( new DoubleWritable(((Aggregator<DoubleWritable>)getAggregator("dangling-current")).getAggregatedValue().get()) );
+ danglingPrevious = ((Aggregator<DoubleWritable>)getAggregator("dangling-current")).getAggregatedValue().get();
((Aggregator<DoubleWritable>)getAggregator("dangling-current")).setAggregatedValue( new DoubleWritable(0L) );
}
Please sign in to comment.
Something went wrong with that request. Please try again.