1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.giraph.io.formats;
19
20 import com.google.common.collect.ImmutableList;
21 import org.apache.giraph.edge.Edge;
22 import org.apache.hadoop.io.IntWritable;
23 import org.apache.hadoop.io.NullWritable;
24 import org.apache.hadoop.io.Text;
25 import org.apache.hadoop.mapreduce.InputSplit;
26 import org.apache.hadoop.mapreduce.TaskAttemptContext;
27
28 import java.io.IOException;
29
30
31
32
33
34
35
36 public class IntNullNullTextInputFormat extends TextVertexInputFormat<
37 IntWritable, NullWritable, NullWritable> {
38 @Override
39 public TextVertexReader createVertexReader(
40 InputSplit split, TaskAttemptContext context) throws IOException {
41 return new IntNullNullNullVertexReader();
42 }
43
44
45
46
47 public class IntNullNullNullVertexReader extends
48 TextVertexReaderFromEachLineProcessed<String> {
49
50 private IntWritable id;
51
52 @Override
53 protected String preprocessLine(Text line) throws IOException {
54 id = new IntWritable(Integer.parseInt(line.toString()));
55 return line.toString();
56 }
57
58 @Override
59 protected IntWritable getId(String line) throws IOException {
60 return id;
61 }
62
63 @Override
64 protected NullWritable getValue(String line) throws IOException {
65 return NullWritable.get();
66 }
67
68 @Override
69 protected Iterable<Edge<IntWritable, NullWritable>> getEdges(String line)
70 throws IOException {
71 return ImmutableList.of();
72 }
73 }
74 }