Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
VertexReader |
|
| 1.0;1 |
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, software | |
13 | * distributed under the License is distributed on an "AS IS" BASIS, | |
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
15 | * See the License for the specific language governing permissions and | |
16 | * limitations under the License. | |
17 | */ | |
18 | ||
19 | package org.apache.giraph.graph; | |
20 | ||
21 | import org.apache.hadoop.io.Writable; | |
22 | import org.apache.hadoop.io.WritableComparable; | |
23 | import org.apache.hadoop.mapreduce.InputSplit; | |
24 | import org.apache.hadoop.mapreduce.TaskAttemptContext; | |
25 | ||
26 | import java.io.IOException; | |
27 | ||
28 | /** | |
29 | * Analogous to {@link RecordReader} for vertices. Will read the vertices | |
30 | * from an input split. | |
31 | * | |
32 | * @param <I> Vertex id | |
33 | * @param <V> Vertex data | |
34 | * @param <E> Edge data | |
35 | * @param <M> Message data | |
36 | */ | |
37 | @SuppressWarnings("rawtypes") | |
38 | public interface VertexReader<I extends WritableComparable, | |
39 | V extends Writable, E extends Writable, M extends Writable> { | |
40 | /** | |
41 | * Use the input split and context to setup reading the vertices. | |
42 | * Guaranteed to be called prior to any other function. | |
43 | * | |
44 | * @param inputSplit Input split to be used for reading vertices. | |
45 | * @param context Context from the task. | |
46 | * @throws IOException | |
47 | * @throws InterruptedException | |
48 | */ | |
49 | void initialize(InputSplit inputSplit, TaskAttemptContext context) | |
50 | throws IOException, InterruptedException; | |
51 | ||
52 | /** | |
53 | * | |
54 | * @return false iff there are no more vertices | |
55 | * @throws IOException | |
56 | * @throws InterruptedException | |
57 | */ | |
58 | boolean nextVertex() throws IOException, InterruptedException; | |
59 | ||
60 | /** | |
61 | * Get the current vertex. | |
62 | * | |
63 | * @return the current vertex which has been read. | |
64 | * nextVertex() should be called first. | |
65 | * @throws IOException | |
66 | * @throws InterruptedException | |
67 | */ | |
68 | Vertex<I, V, E, M> getCurrentVertex() | |
69 | throws IOException, InterruptedException; | |
70 | ||
71 | /** | |
72 | * Close this {@link VertexReader} to future operations. | |
73 | * | |
74 | * @throws IOException | |
75 | */ | |
76 | void close() throws IOException; | |
77 | ||
78 | /** | |
79 | * How much of the input has the {@link VertexReader} consumed i.e. | |
80 | * has been processed by? | |
81 | * | |
82 | * @return Progress from <code>0.0</code> to <code>1.0</code>. | |
83 | * @throws IOException | |
84 | * @throws InterruptedException | |
85 | */ | |
86 | float getProgress() throws IOException, InterruptedException; | |
87 | } |