giraph-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Bishop <jbishop....@gmail.com>
Subject Re: Number of messages to all vertices for the current supersetp
Date Fri, 16 Nov 2012 21:36:32 GMT
Hi,

I found a solution for this which seems to work...here it is in case
someone else finds this useful.

1) Create a new worker context class which registers a
LongSumAggregator...make sure to set the worker context in your job to this
class.

public class MyContext extends WorkerContext {
static String MESSAGE_COUNT = "MESSAGE_COUNT";
long messages = 0;
@Override
public void preApplication() throws InstantiationException,
IllegalAccessException {
registerAggregator(MESSAGE_COUNT, LongSumAggregator.class);
}
@Override
public void postApplication() {
}
@Override
public void preSuperstep() {
LongSumAggregator ag = (LongSumAggregator)getAggregator(MESSAGE_COUNT);
messages = ag.getAggregatedValue().get();
ag.setAggregatedValue(new LongWritable(0L));
}
@Override
public void postSuperstep() {
}
long getSuperstepMessageCount() {
return messages;
}
}

2) In compute increment this aggregator by the number of messages sent...

LongSumAggregator messageAggregator =
((LongSumAggregator)getAggregator(MyContext.MESSAGE_COUNT));
for (VertexIndex i : this) {
messageAggregator.aggregate(1L);
}

3) retrieve the number of messages being sent to this superstep...

long numMessages =
((GraphContext)getWorkerContext()).getSuperstepMessageCount();

That's it - let me know if I missed something.

Jon



On Wed, Nov 14, 2012 at 5:38 PM, Jonathan Bishop <jbishop.rwc@gmail.com>wrote:

> Hi,
>
> It would be useful to know if there are no messages being sent to any
> vertex during the current super-step during "calculate".
>
> Of course, the number of messages sent to the particular vertex being
> computed is known. What I need is the sum of messages being sent to all
> vertices.
>
> Thanks,
>
> Jon
>

Mime
View raw message