Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
EdgeWithSource |
|
| 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.io.iterables; | |
20 | ||
21 | import org.apache.giraph.edge.ReusableEdge; | |
22 | import org.apache.hadoop.io.Writable; | |
23 | import org.apache.hadoop.io.WritableComparable; | |
24 | ||
25 | /** | |
26 | * Wrapper for edge and its source id | |
27 | * | |
28 | * @param <I> Vertex id | |
29 | * @param <E> Edge data | |
30 | */ | |
31 | public class EdgeWithSource<I extends WritableComparable, | |
32 | E extends Writable> { | |
33 | /** Source id */ | |
34 | private I sourceVertexId; | |
35 | /** Edge */ | |
36 | private ReusableEdge<I, E> edge; | |
37 | ||
38 | /** | |
39 | * Constructor | |
40 | */ | |
41 | 0 | public EdgeWithSource() { |
42 | 0 | } |
43 | ||
44 | /** | |
45 | * Constructor with source id and edge | |
46 | * | |
47 | * @param sourceVertexId Source id | |
48 | * @param edge Edge | |
49 | */ | |
50 | 0 | public EdgeWithSource(I sourceVertexId, ReusableEdge<I, E> edge) { |
51 | 0 | this.sourceVertexId = sourceVertexId; |
52 | 0 | this.edge = edge; |
53 | 0 | } |
54 | ||
55 | public I getSourceVertexId() { | |
56 | 0 | return sourceVertexId; |
57 | } | |
58 | ||
59 | public void setSourceVertexId(I sourceVertexId) { | |
60 | 0 | this.sourceVertexId = sourceVertexId; |
61 | 0 | } |
62 | ||
63 | public ReusableEdge<I, E> getEdge() { | |
64 | 0 | return edge; |
65 | } | |
66 | ||
67 | public void setEdge(ReusableEdge<I, E> edge) { | |
68 | 0 | this.edge = edge; |
69 | 0 | } |
70 | ||
71 | public I getTargetVertexId() { | |
72 | 0 | return edge.getTargetVertexId(); |
73 | } | |
74 | ||
75 | /** | |
76 | * Set target vertex id of this edge | |
77 | * | |
78 | * @param targetVertexId Target vertex id | |
79 | */ | |
80 | public void setTargetVertexId(I targetVertexId) { | |
81 | 0 | edge.setTargetVertexId(targetVertexId); |
82 | 0 | } |
83 | ||
84 | public E getEdgeValue() { | |
85 | 0 | return edge.getValue(); |
86 | } | |
87 | ||
88 | /** | |
89 | * Set the value of this edge | |
90 | * | |
91 | * @param value Edge value | |
92 | */ | |
93 | public void setEdgeValue(E value) { | |
94 | 0 | edge.setValue(value); |
95 | 0 | } |
96 | } |