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.io.MappingReader; |
23 | |
import org.apache.giraph.mapping.MappingEntry; |
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 | |
|
39 | |
|
40 | |
public class MappingReaderWrapper<I extends WritableComparable, |
41 | |
V extends Writable, E extends Writable, B extends Writable> |
42 | |
extends MappingReader<I, V, E, B> { |
43 | |
|
44 | |
private GiraphReader<MappingEntry<I, B>> mappingReader; |
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
private IteratorToReaderWrapper<MappingEntry<I, B>> iterator; |
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | 0 | public MappingReaderWrapper(GiraphReader<MappingEntry<I, B>> mappingReader) { |
57 | 0 | this.mappingReader = mappingReader; |
58 | 0 | iterator = new IteratorToReaderWrapper<>(mappingReader); |
59 | 0 | } |
60 | |
|
61 | |
@Override |
62 | |
public void setConf( |
63 | |
ImmutableClassesGiraphConfiguration<I, V, E> conf) { |
64 | 0 | super.setConf(conf); |
65 | 0 | conf.configureIfPossible(mappingReader); |
66 | 0 | } |
67 | |
|
68 | |
@Override |
69 | |
public boolean nextEntry() throws IOException, InterruptedException { |
70 | 0 | return iterator.nextObject(); |
71 | |
} |
72 | |
|
73 | |
@Override |
74 | |
public MappingEntry<I, B> getCurrentEntry() |
75 | |
throws IOException, InterruptedException { |
76 | 0 | return iterator.getCurrentObject(); |
77 | |
} |
78 | |
|
79 | |
|
80 | |
@Override |
81 | |
public void initialize(InputSplit inputSplit, |
82 | |
TaskAttemptContext context) throws IOException, InterruptedException { |
83 | 0 | mappingReader.initialize(inputSplit, context); |
84 | 0 | } |
85 | |
|
86 | |
@Override |
87 | |
public void close() throws IOException { |
88 | 0 | mappingReader.close(); |
89 | 0 | } |
90 | |
|
91 | |
@Override |
92 | |
public float getProgress() throws IOException, InterruptedException { |
93 | 0 | return mappingReader.getProgress(); |
94 | |
} |
95 | |
} |