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