giraph-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alessandro Presta <alessan...@fb.com>
Subject Re: How to create new vertices in runtime?
Date Sun, 22 Jul 2012 20:53:57 GMT
Hi Marcin,

The BspUtils factories are not meant for mutating the graph in user code. Your vertex should
extend MutableVertex and use its methods to add vertices/edges. All mutation requests are
processed before the next superstep and rules for handling conflicts can be specified.

Hope it helps,

Alessandro

From: Marcin Biczak <marcinbiczak@gmail.com<mailto:marcinbiczak@gmail.com>>
Reply-To: "user@giraph.apache.org<mailto:user@giraph.apache.org>" <user@giraph.apache.org<mailto:user@giraph.apache.org>>
Date: Sunday, July 22, 2012 9:48 PM
To: "user@giraph.apache.org<mailto:user@giraph.apache.org>" <user@giraph.apache.org<mailto:user@giraph.apache.org>>
Subject: How to create new vertices in runtime?

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