Hi everyone,
I am currently trying to write a procedure using the Pregel-API, where I would like to use the compute-method, to store each of the incoming messages for a node. However, I am kind of struggling with the Messages-object right now. The problem lies in the fact, that the Messages-class implements an Iterable and the node-schema only allows for an array of doubles to be stored. Hence, I must somehow cast the Messages-Iterable into an array of doubles. Since this happens on each node, I am looking for a rather efficient way of doing so. E.g. for the schema below, how to I get to the array of doubles defined by REACHEDBY-field...
@Override
public PregelSchema schema (DistanceConfig config) {
return new PregelSchema.Builder()
.add(REACHEDBY, ValueType.DOUBLE_ARRAY, Visibility.PUBLIC)
.add(DISTANCE, ValueType.DOUBLE, Visibility.PUBLIC)
.build();
}
... From the Messages-object passed to the compute-method:
@Override
public void compute(ComputeContext<DistanceConfig> context, Messages messages) {
.
.
.
else if (step <= maxIter) {
if (!messages.isEmpty()) {
??? What to do here ???
}
.
.
.
}
Has anyone else any experience with that? What would be the preferred way of performing this kind of operation?
Thanks a lot,
Lorenz