1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.giraph.examples;
20
21 import org.apache.giraph.graph.Vertex;
22 import org.apache.giraph.io.formats.TextVertexOutputFormat;
23 import org.apache.hadoop.io.FloatWritable;
24 import org.apache.hadoop.io.IntWritable;
25 import org.apache.hadoop.io.LongWritable;
26 import org.apache.hadoop.io.Text;
27 import org.apache.hadoop.mapreduce.TaskAttemptContext;
28
29 import java.io.IOException;
30
31
32
33
34 public class SimpleTextVertexOutputFormat extends
35 TextVertexOutputFormat<LongWritable, IntWritable, FloatWritable> {
36
37
38
39 private class SimpleTextVertexWriter extends TextVertexWriter {
40 @Override
41 public void writeVertex(
42 Vertex<LongWritable, IntWritable, FloatWritable> vertex)
43 throws IOException, InterruptedException {
44 getRecordWriter().write(
45 new Text(vertex.getId().toString()),
46 new Text(vertex.getValue().toString()));
47 }
48 }
49
50 @Override
51 public TextVertexWriter createVertexWriter(TaskAttemptContext context)
52 throws IOException, InterruptedException {
53 return new SimpleTextVertexWriter();
54 }
55 }