You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@giraph.apache.org by Panagiotis Liakos <p....@di.uoa.gr> on 2015/09/07 15:59:26 UTC

how should I configure ByteArrayEdges?

Hello all,

I am trying to create a ByteArrayEdges object for a given vertex. All
out-neighbors can be represented using Integers and there are no
weights in the graph so I am using Edge<IntWritable, NullWritable> to
populate my object.

Please see the following example:

@Test
public void error(){
   GiraphConfiguration giraphConfiguration = new GiraphConfiguration();
   giraphConfiguration.setComputationClass(TestComputation.class);
   giraphConfiguration.setOutEdgesClass(ByteArrayEdges.class);
   ImmutableClassesGiraphConfiguration immutableClassesGiraphConfiguration =
    new ImmutableClassesGiraphConfiguration(giraphConfiguration);
ByteArrayEdges<IntWritable, NullWritable> edges =
    (ByteArrayEdges<IntWritable, NullWritable>)
immutableClassesGiraphConfiguration.createOutEdges();
   List<Edge<IntWritable, NullWritable>> initialEdges = Lists.newArrayList(
       EdgeFactory.create(new IntWritable(1)),
       EdgeFactory.create(new IntWritable(2)));
edges.initialize((Iterable)initialEdges);
for(Iterator<Edge<IntWritable, NullWritable>> edgeIter =
edges.iterator(); edgeIter.hasNext();){
    edgeIter.next();
    }
}

This results in correctly building the object which dedicates 4 bytes
for each out-neighbor.
However, when iterating over the edges with a ByteArrayEdgeIterator I
receive an IllegalStateException. (java.lang.IllegalStateException:
next: Failed on pos 8 edge (targetVertexId = 8589934593, value = 0.0))

I inserted a printStackTrace() call and I get this error:
java.io.IOException: ensureRemaining: Only 0 bytes remaining, trying to read 8

Does anyone know how I am supposed to configure this so that the
iterator behaves normally?

--Panagiotis