1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.giraph.io.internal; |
20 | |
|
21 | |
import org.apache.giraph.io.VertexInputFormat; |
22 | |
import org.apache.giraph.io.VertexReader; |
23 | |
import org.apache.giraph.job.HadoopUtils; |
24 | |
import org.apache.hadoop.conf.Configuration; |
25 | |
import org.apache.hadoop.io.Writable; |
26 | |
import org.apache.hadoop.io.WritableComparable; |
27 | |
import org.apache.hadoop.mapreduce.InputSplit; |
28 | |
import org.apache.hadoop.mapreduce.JobContext; |
29 | |
import org.apache.hadoop.mapreduce.TaskAttemptContext; |
30 | |
|
31 | |
import java.io.DataInput; |
32 | |
import java.io.DataOutput; |
33 | |
import java.io.IOException; |
34 | |
import java.util.List; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
public class WrappedVertexInputFormat<I extends WritableComparable, |
49 | |
V extends Writable, E extends Writable> |
50 | |
extends VertexInputFormat<I, V, E> { |
51 | |
|
52 | |
private VertexInputFormat<I, V, E> originalInputFormat; |
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
public WrappedVertexInputFormat( |
60 | 0 | VertexInputFormat<I, V, E> vertexInputFormat) { |
61 | 0 | originalInputFormat = vertexInputFormat; |
62 | 0 | } |
63 | |
|
64 | |
@Override |
65 | |
public void checkInputSpecs(Configuration conf) { |
66 | 0 | originalInputFormat.checkInputSpecs(getConf()); |
67 | 0 | } |
68 | |
|
69 | |
@Override |
70 | |
public List<InputSplit> getSplits(JobContext context, |
71 | |
int minSplitCountHint) throws IOException, InterruptedException { |
72 | 0 | return originalInputFormat.getSplits( |
73 | 0 | HadoopUtils.makeJobContext(getConf(), context), |
74 | |
minSplitCountHint); |
75 | |
} |
76 | |
|
77 | |
@Override |
78 | |
public VertexReader<I, V, E> createVertexReader(InputSplit split, |
79 | |
TaskAttemptContext context) throws IOException { |
80 | 0 | final VertexReader<I, V, E> vertexReader = |
81 | 0 | originalInputFormat.createVertexReader(split, |
82 | 0 | HadoopUtils.makeTaskAttemptContext(getConf(), context)); |
83 | 0 | return new WrappedVertexReader<I, V, E>(vertexReader, getConf()); |
84 | |
} |
85 | |
|
86 | |
@Override |
87 | |
public void writeInputSplit(InputSplit inputSplit, |
88 | |
DataOutput dataOutput) throws IOException { |
89 | 0 | originalInputFormat.writeInputSplit(inputSplit, dataOutput); |
90 | 0 | } |
91 | |
|
92 | |
@Override |
93 | |
public InputSplit readInputSplit( |
94 | |
DataInput dataInput) throws IOException, ClassNotFoundException { |
95 | 0 | return originalInputFormat.readInputSplit(dataInput); |
96 | |
} |
97 | |
} |