This project has retired. For details please refer to its
Attic page.
VertexReaderWrapper xref
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 public VertexReaderWrapper(GiraphReader<Vertex<I, V, E>> vertexReader) {
51 this.vertexReader = vertexReader;
52 iterator = new IteratorToReaderWrapper<Vertex<I, V, E>>(vertexReader);
53 }
54
55 @Override
56 public void setConf(
57 ImmutableClassesGiraphConfiguration<I, V, E> conf) {
58 super.setConf(conf);
59 conf.configureIfPossible(vertexReader);
60 }
61
62 @Override
63 public boolean nextVertex() throws IOException, InterruptedException {
64 return iterator.nextObject();
65 }
66
67 @Override
68 public Vertex<I, V, E> getCurrentVertex() throws IOException,
69 InterruptedException {
70 return iterator.getCurrentObject();
71 }
72
73 @Override
74 public void initialize(InputSplit inputSplit,
75 TaskAttemptContext context) throws IOException, InterruptedException {
76 vertexReader.initialize(inputSplit, context);
77 }
78
79 @Override
80 public void close() throws IOException {
81 vertexReader.close();
82 }
83
84 @Override
85 public float getProgress() throws IOException, InterruptedException {
86 return vertexReader.getProgress();
87 }
88 }