giraph-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcin Biczak <marcinbic...@gmail.com>
Subject How to create new vertices in runtime?
Date Sun, 22 Jul 2012 20:48:57 GMT
Hi

Is it possible to create new vertices, during runtime and "execute them"? I
would like to create N new vertices within compute() method. Currently I
use the same approach for vertex initialization as in Readers (BspUtils).
However the newly created vertices do not execute the compute() method.

public void compute(Iterator<Text> msgIterator) throws IOException {
        if(this.getSuperstep() == 0) {
            // createVertex
            BasicVertex<VIntWritable, Text, VIntWritable, Text> vertex =
BspUtils.<VIntWritable, Text, VIntWritable, Text>createVertex(getContext()
.getConfiguration());
            VIntWritable id = new VIntWritable(new Random().nextInt(100));
            Map<VIntWritable, VIntWritable> edges = Maps.newHashMap();
            edges.put(new VIntWritable(16), new VIntWritable(0));
            vertex.initialize(id, new Text(), edges, null);
            LOG.info("@@@ newly created vertex = "+id);
        } else {
            // stop
            LOG.info("@@@ vertex = "+this.getVertexId());
            voteToHalt();
        }
    }

Logs:
...
// log new vertex
INFO org.test.giraph.test.VertexCreation: @@@ new vertex created = 11
INFO org.test.giraph.test.VertexCreation: @@@ new vertex created = 55
INFO org.test.giraph.test.VertexCreation: @@@ new vertex created = 92
INFO org.test.giraph.test.VertexCreation: @@@ new vertex created = 63
INFO org.test.giraph.test.VertexCreation: @@@ new vertex created = 58
INFO org.test.giraph.test.VertexCreation: @@@ new vertex created = 45
INFO org.test.giraph.test.VertexCreation: @@@ new vertex created = 36
INFO org.test.giraph.test.VertexCreation: @@@ new vertex created = 45
...
// log all vertices
INFO org.test.giraph.test.VertexCreation: @@@ vertex = 1
INFO org.test.giraph.test.VertexCreation: @@@ vertex = 2
INFO org.test.giraph.test.VertexCreation: @@@ vertex = 222
INFO org.test.giraph.test.VertexCreation: @@@ vertex = 3
INFO org.test.giraph.test.VertexCreation: @@@ vertex = 4
INFO org.test.giraph.test.VertexCreation: @@@ vertex = 5
INFO org.test.giraph.test.VertexCreation: @@@ vertex = 6
INFO org.test.giraph.test.VertexCreation: @@@ vertex = 111
INFO org.test.giraph.test.VertexCreation: @@@ vertex = 333

Where am I making a mistake?

Best regards
Marcin

Mime
View raw message