1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.giraph.examples;
20
21 import java.io.IOException;
22 import org.apache.giraph.bsp.BspInputSplit;
23 import org.apache.giraph.conf.LongConfOption;
24 import org.apache.giraph.io.EdgeReader;
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.TaskAttemptContext;
29
30
31
32
33
34
35
36
37 @SuppressWarnings("rawtypes")
38 public abstract class GeneratedEdgeReader<
39 I extends WritableComparable,
40 E extends Writable>
41 extends EdgeReader<I, E> {
42
43 public static final LongConfOption DEFAULT_READER_EDGES =
44 new LongConfOption("GeneratedEdgeReader.reader_edges", 10,
45 "Default edges produced by this reader");
46
47 protected long recordsRead = 0;
48
49 protected long totalRecords = 0;
50
51 protected BspInputSplit inputSplit = null;
52
53
54
55
56 public GeneratedEdgeReader() {
57 }
58
59 @Override
60 public final void initialize(InputSplit inputSplit,
61 TaskAttemptContext context) throws IOException {
62 totalRecords = DEFAULT_READER_EDGES.get(getConf());
63 this.inputSplit = (BspInputSplit) inputSplit;
64 }
65
66 @Override
67 public void close() throws IOException {
68 }
69
70 @Override
71 public final float getProgress() throws IOException {
72 return recordsRead * 100.0f / totalRecords;
73 }
74 }