Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Large scale graph processing with apache giraph

Large scale graph processing with apache giraph

André Kelpe

May 23, 2012
Tweet

More Decks by André Kelpe

Other Decks in Programming

Transcript

  1. execution of superstep S Each vertex processes messages generated in

    S-1 and send messages to be processed in S+1 and determines to halt.
  2. giraph simple map jobs in master worker setup. coordination via

    zookeeper. messaging via own RPC protocol. in memory processing. custom input and output formats.
  3. current status version 0.1 released compatible with a multitude of

    hadoop versions (we use CDH3 at work) still lots of things to do, join the fun!
  4. Vertex-API /** *@param <I> vertex id * @param <V> vertex

    data * @param <E> edge data * @param <M> message data */ class BasicVertex<I extends WritableComparable, V extends Writable, E extends Writable, M extends Writable> void compute(Iterator<M> msgIterator); void sendMsg(I id, M msg); void voteToHalt();
  5. private boolean isSource() { return (getVertexId().get() == getContext().getConfiguration().getLong(SOURCE_ID, SOURCE_ID_DEFAULT)); }

    @Override public void compute(Iterator<DoubleWritable> msgIterator) { if (getSuperstep() == 0) { setVertexValue(new DoubleWritable(Double.MAX_VALUE)); } double minDist = isSource() ? 0d : Double.MAX_VALUE; while (msgIterator.hasNext()) { minDist = Math.min(minDist, msgIterator.next().get()); } if (minDist < getVertexValue().get()) { setVertexValue(new DoubleWritable(minDist)); for (Edge<LongWritable, FloatWritable> edge : getOutEdgeMap().values()) { sendMsg(edge.getDestVertexId(), new DoubleWritable(minDist + edge.getEdgeValue().get())); } } voteToHalt(); }
  6. GiraphJob job = new GiraphJob(getConf(), getClass().getName()); job.setVertexClass(SimpleShortestPathVertex.class); job.setVertexInputFormatClass(SimpleShortestPathsVertexInputFormat.class); job.setVertexOutputFormatClass( SimpleShortestPathsVertexOutputFormat.class);

    FileInputFormat.addInputPath(job, new Path(„/foo/bar/baz“)); FileOutputFormat.setOutputPath(job, new Path(„/foo/bar/quux“)); job.getConfiguration().setLong(SimpleShortestPathsVertex.SOURCE_ID, Long.parseLong(argArray[2])); job.setWorkerConfiguration(minWorkers, maxWorkers), 100.0f); GiraphJob