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 java.io.IOException; |
22 | |
|
23 | |
import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration; |
24 | |
import org.apache.giraph.edge.Edge; |
25 | |
import org.apache.giraph.io.EdgeReader; |
26 | |
import org.apache.hadoop.io.Writable; |
27 | |
import org.apache.hadoop.io.WritableComparable; |
28 | |
import org.apache.hadoop.mapreduce.InputSplit; |
29 | |
import org.apache.hadoop.mapreduce.TaskAttemptContext; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
public class EdgeReaderWrapper<I extends WritableComparable, |
38 | |
E extends Writable> extends EdgeReader<I, E> { |
39 | |
|
40 | |
private GiraphReader<EdgeWithSource<I, E>> edgeReader; |
41 | |
|
42 | |
private IteratorToReaderWrapper<EdgeWithSource<I, E>> iterator; |
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | 0 | public EdgeReaderWrapper(GiraphReader<EdgeWithSource<I, E>> edgeReader) { |
50 | 0 | this.edgeReader = edgeReader; |
51 | 0 | iterator = new IteratorToReaderWrapper<EdgeWithSource<I, E>>(edgeReader); |
52 | 0 | } |
53 | |
|
54 | |
@Override |
55 | |
public void setConf( |
56 | |
ImmutableClassesGiraphConfiguration<I, Writable, E> conf) { |
57 | 0 | super.setConf(conf); |
58 | 0 | conf.configureIfPossible(edgeReader); |
59 | 0 | } |
60 | |
|
61 | |
@Override |
62 | |
public boolean nextEdge() throws IOException, InterruptedException { |
63 | 0 | return iterator.nextObject(); |
64 | |
} |
65 | |
|
66 | |
@Override |
67 | |
public I getCurrentSourceId() throws IOException, InterruptedException { |
68 | 0 | return iterator.getCurrentObject().getSourceVertexId(); |
69 | |
} |
70 | |
|
71 | |
@Override |
72 | |
public Edge<I, E> getCurrentEdge() throws IOException, InterruptedException { |
73 | 0 | return iterator.getCurrentObject().getEdge(); |
74 | |
} |
75 | |
|
76 | |
@Override |
77 | |
public void initialize(InputSplit inputSplit, |
78 | |
TaskAttemptContext context) throws IOException, InterruptedException { |
79 | 0 | edgeReader.initialize(inputSplit, context); |
80 | 0 | } |
81 | |
|
82 | |
@Override |
83 | |
public void close() throws IOException { |
84 | 0 | edgeReader.close(); |
85 | 0 | } |
86 | |
|
87 | |
@Override |
88 | |
public float getProgress() throws IOException, InterruptedException { |
89 | 0 | return edgeReader.getProgress(); |
90 | |
} |
91 | |
} |