[
https://issues.apache.org/jira/browse/HAMA-838?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13866154#comment-13866154
]
Edward J. Yoon commented on HAMA-838:
-------------------------------------
I've refactored pagerank example's compute() code as below:
{code}
@Override
public void compute(Iterable<DoubleWritable> messages) throws IOException {
// initialize this vertex to 1 / count of global vertices in this graph
if (this.getSuperstepCount() == 0) {
setValue(new DoubleWritable(1.0 / this.getNumVertices()));
} else if (this.getSuperstepCount() >= 1) {
double sum = 0;
for (DoubleWritable msg : messages) {
sum += msg.get();
}
double alpha = (1.0d - DAMPING_FACTOR) / this.getNumVertices();
setValue(new DoubleWritable(alpha + (sum * DAMPING_FACTOR)));
aggregate(AVG_AGGREGATOR, this.getValue());
}
// if we have not reached our global error yet, then proceed.
DoubleWritable globalError = (DoubleWritable)
getAggregatedValue(AVG_AGGREGATOR);
if (globalError != null && this.getSuperstepCount() > 2
&& MAXIMUM_CONVERGENCE_ERROR > globalError.get()) {
voteToHalt();
} else {
// in each superstep we are going to send a new rank to our neighbours
sendMessageToNeighbors(new DoubleWritable(this.getValue().get()
/ this.getEdges().size()));
}
}
}
{code}
> Add custom aggregators
> ----------------------
>
> Key: HAMA-838
> URL: https://issues.apache.org/jira/browse/HAMA-838
> Project: Hama
> Issue Type: Improvement
> Components: graph
> Affects Versions: 0.6.3
> Reporter: Anastasis Andronidis
> Assignee: Anastasis Andronidis
> Labels: features, patch
> Fix For: 0.7.0
>
> Attachments: HAMA-838.patch, HAMA-838_v02.patch
>
>
> This is a patch that adds custom aggregators.
> I also wrote an example of how you can use them.
> Implementation features:
> * Register the aggregators by name.
> * Custom aggregators are skipped when there are no messages to process
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)