Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
EdgeStore |
|
| 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.edge; | |
20 | ||
21 | import org.apache.giraph.utils.VertexIdEdges; | |
22 | import org.apache.hadoop.io.Writable; | |
23 | import org.apache.hadoop.io.WritableComparable; | |
24 | ||
25 | import java.io.DataInput; | |
26 | import java.io.DataOutput; | |
27 | import java.io.IOException; | |
28 | ||
29 | /** | |
30 | * Collects incoming edges for vertices owned by this worker. | |
31 | * | |
32 | * @param <I> Vertex id | |
33 | * @param <V> Vertex value | |
34 | * @param <E> Edge value | |
35 | */ | |
36 | public interface EdgeStore<I extends WritableComparable, | |
37 | V extends Writable, E extends Writable> { | |
38 | /** | |
39 | * Add edges belonging to a given partition on this worker. | |
40 | * Note: This method is thread-safe. | |
41 | * | |
42 | * @param partitionId Partition id for the incoming edges. | |
43 | * @param edges Incoming edges | |
44 | */ | |
45 | void addPartitionEdges(int partitionId, VertexIdEdges<I, E> edges); | |
46 | ||
47 | /** | |
48 | * Move all edges from temporary storage to their source vertices. | |
49 | * Note: this method is not thread-safe and is called once all vertices and | |
50 | * edges are read in INPUT_SUPERSTEP. | |
51 | */ | |
52 | void moveEdgesToVertices(); | |
53 | ||
54 | /** | |
55 | * Deserialize the edges of a given partition, and removes the associated data | |
56 | * from the store. | |
57 | * Note: This method is not thread-safe (i.e. should not be called for the | |
58 | * same partition at the same time). | |
59 | * | |
60 | * @param partitionId Id of partition to deserialize | |
61 | * @param output Output to write the edge store to | |
62 | */ | |
63 | void writePartitionEdgeStore(int partitionId, DataOutput output) | |
64 | throws IOException; | |
65 | ||
66 | /** | |
67 | * Serialize the edges of a given partition, and adds it to the partition | |
68 | * store (assumes that the edge store does not have any edge from the | |
69 | * partition already). | |
70 | * Note: This method is not thread-safe (i.e. should not be called for the | |
71 | * same partition at the same time). | |
72 | * | |
73 | * @param partitionId Id of partition to serialize | |
74 | * @param input Input to read the partition from | |
75 | */ | |
76 | void readPartitionEdgeStore(int partitionId, DataInput input) | |
77 | throws IOException; | |
78 | ||
79 | /** | |
80 | * Check if edge store has edge for a given partition | |
81 | * | |
82 | * @param partitionId Id of partition | |
83 | * @return True iff edge store have messages for the given partition | |
84 | */ | |
85 | boolean hasEdgesForPartition(int partitionId); | |
86 | } |