user349
user349

Reputation: 11

How we know the value of Messages used in Giraph

How we know the value of message.get() in SimpleShortestPathsComputation?

if we have Vertex<DoubleWritable, DoubleWritable, DoubleWritable> vertex instead of

Vertex<LongWritable, DoubleWritable, FloatWritable> vertex

How we know that Messages has the value of MinDist and not e.g VertextID or EdgeValue?

@Override   public void compute(
      Vertex<LongWritable, DoubleWritable, FloatWritable> vertex,
      Iterable<DoubleWritable> messages) throws IOException {
    if (getSuperstep() == 0) {
      vertex.setValue(new DoubleWritable(Double.MAX_VALUE));
    }
    double minDist = isSource(vertex) ? 0d : Double.MAX_VALUE;
    for (DoubleWritable message : messages) {
      minDist = Math.min(minDist, message.get());
    }

Thank you

Upvotes: 1

Views: 101

Answers (1)

peter
peter

Reputation: 15139

Message will have the value you will put inside via the sendMessage method. Just because they have the same type, doesn't mean that things can get mixed up. That's not how the serialisation / deserialisation works in Giraph.

If you don't trust it, you can also have a look at the code here: https://github.com/apache/giraph

Besides that you mixed up a thing, Message doesn't contain the min distance, The min distance is saved inside the vertex' value. The message contains a distance to the source vertex, when it passes the current vertex and is actually the edge data (you called it edge value). The message data, or edge data, is actually of type FloatWritable in the original case - see the code here:

....
/**
 * Class which holds vertex id, data and edges.
 *
 * @param <I> Vertex id
 * @param <V> Vertex data
 * @param <E> Edge data
 */
public interface Vertex<I extends WritableComparable,
    V extends Writable, E extends Writable> extends
    ImmutableClassesGiraphConfigurable<I, V, E> {
    ....
}

Upvotes: 1

Related Questions