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 org.apache.giraph.edge.Edge;
21 import org.apache.giraph.edge.EdgeFactory;
22 import org.apache.hadoop.io.DoubleWritable;
23 import org.apache.hadoop.io.Text;
24 import org.apache.hadoop.mapreduce.InputSplit;
25 import org.apache.hadoop.mapreduce.TaskAttemptContext;
26
27
28
29
30
31
32 public class TextDoubleDoubleAdjacencyListVertexInputFormat
33 extends AdjacencyListTextVertexInputFormat<Text, DoubleWritable,
34 DoubleWritable> {
35
36 @Override
37 public AdjacencyListTextVertexReader createVertexReader(InputSplit split,
38 TaskAttemptContext context) {
39 return new TextDoubleDoubleAdjacencyListVertexReader(null);
40 }
41
42
43
44
45
46 protected class TextDoubleDoubleAdjacencyListVertexReader extends
47 AdjacencyListTextVertexReader {
48
49
50
51
52
53
54
55 public TextDoubleDoubleAdjacencyListVertexReader(LineSanitizer
56 lineSanitizer) {
57 super(lineSanitizer);
58 }
59
60 @Override
61 public Text decodeId(String s) {
62 return new Text(s);
63 }
64
65 @Override
66 public DoubleWritable decodeValue(String s) {
67 return new DoubleWritable(Double.parseDouble(s));
68 }
69
70 @Override
71 public Edge<Text, DoubleWritable> decodeEdge(String s1, String s2) {
72 return EdgeFactory.create(new Text(s1),
73 new DoubleWritable(Double.parseDouble(s2)));
74 }
75 }
76
77 }