利用log4j
package org.apache.giraph.examples;
import java.io.IOException;
import org.apache.giraph.edge.Edge;
import org.apache.giraph.graph.BasicComputation;
import org.apache.giraph.graph.Vertex;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.log4j.Logger;
public class InlinkCountComputation extends BasicComputation<IntWritable, IntWritable,
NullWritable, IntWritable>{
private static final Logger LOG = Logger.getLogger(InlinkCountComputation.class);
@Override
public void compute(Vertex<IntWritable, IntWritable, NullWritable> vertex,
Iterable<IntWritable> messages) throws IOException {
if(getSuperstep() == 0) {
vertex.setValue(new IntWritable(0));
for (Edge<IntWritable, NullWritable> edge : vertex
.getEdges()) {
sendMessage(edge.getTargetVertexId(),new IntWritable(1));
}
} else {
for (IntWritable message : messages) {
vertex.setValue( new IntWritable(vertex.getValue().get() + message.get()));
}
vertex.voteToHalt();
}
}
}
687

被折叠的 条评论
为什么被折叠?



