1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.giraph.io.iterables; |
20 | |
|
21 | |
import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration; |
22 | |
import org.apache.giraph.graph.Vertex; |
23 | |
import org.apache.giraph.io.VertexReader; |
24 | |
import org.apache.hadoop.io.Writable; |
25 | |
import org.apache.hadoop.io.WritableComparable; |
26 | |
import org.apache.hadoop.mapreduce.InputSplit; |
27 | |
import org.apache.hadoop.mapreduce.TaskAttemptContext; |
28 | |
|
29 | |
import java.io.IOException; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
public class VertexReaderWrapper<I extends WritableComparable, |
39 | |
V extends Writable, E extends Writable> extends VertexReader<I, V, E> { |
40 | |
|
41 | |
private GiraphReader<Vertex<I, V, E>> vertexReader; |
42 | |
|
43 | |
private IteratorToReaderWrapper<Vertex<I, V, E>> iterator; |
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | 0 | public VertexReaderWrapper(GiraphReader<Vertex<I, V, E>> vertexReader) { |
51 | 0 | this.vertexReader = vertexReader; |
52 | 0 | iterator = new IteratorToReaderWrapper<Vertex<I, V, E>>(vertexReader); |
53 | 0 | } |
54 | |
|
55 | |
@Override |
56 | |
public void setConf( |
57 | |
ImmutableClassesGiraphConfiguration<I, V, E> conf) { |
58 | 0 | super.setConf(conf); |
59 | 0 | conf.configureIfPossible(vertexReader); |
60 | 0 | } |
61 | |
|
62 | |
@Override |
63 | |
public boolean nextVertex() throws IOException, InterruptedException { |
64 | 0 | return iterator.nextObject(); |
65 | |
} |
66 | |
|
67 | |
@Override |
68 | |
public Vertex<I, V, E> getCurrentVertex() throws IOException, |
69 | |
InterruptedException { |
70 | 0 | return iterator.getCurrentObject(); |
71 | |
} |
72 | |
|
73 | |
@Override |
74 | |
public void initialize(InputSplit inputSplit, |
75 | |
TaskAttemptContext context) throws IOException, InterruptedException { |
76 | 0 | vertexReader.initialize(inputSplit, context); |
77 | 0 | } |
78 | |
|
79 | |
@Override |
80 | |
public void close() throws IOException { |
81 | 0 | vertexReader.close(); |
82 | 0 | } |
83 | |
|
84 | |
@Override |
85 | |
public float getProgress() throws IOException, InterruptedException { |
86 | 0 | return vertexReader.getProgress(); |
87 | |
} |
88 | |
} |