1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * 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 and16 * limitations under the License.17 */1819package org.apache.giraph.io.iterables;
2021import org.apache.giraph.edge.ReusableEdge;
22import org.apache.hadoop.io.Writable;
23import org.apache.hadoop.io.WritableComparable;
2425/**26 * Wrapper for edge and its source id27 *28 * @param <I> Vertex id29 * @param <E> Edge data30 */31publicclass EdgeWithSource<I extends WritableComparable,
32 E extends Writable> {
33/** Source id */34private I sourceVertexId;
35/**Edge */36private ReusableEdge<I, E> edge;
3738/**39 * Constructor40 */41publicEdgeWithSource() {
42 }
4344/**45 * Constructor with source id and edge46 *47 * @param sourceVertexId Source id48 * @param edge Edge49 */50publicEdgeWithSource(I sourceVertexId, ReusableEdge<I, E> edge) {
51this.sourceVertexId = sourceVertexId;
52this.edge = edge;
53 }
5455public I getSourceVertexId() {
56return sourceVertexId;
57 }
5859publicvoid setSourceVertexId(I sourceVertexId) {
60this.sourceVertexId = sourceVertexId;
61 }
6263public ReusableEdge<I, E> getEdge() {
64return edge;
65 }
6667publicvoid setEdge(ReusableEdge<I, E> edge) {
68this.edge = edge;
69 }
7071public I getTargetVertexId() {
72return edge.getTargetVertexId();
73 }
7475/**76 * Set target vertex id of this edge77 *78 * @param targetVertexId Target vertex id79 */80publicvoid setTargetVertexId(I targetVertexId) {
81 edge.setTargetVertexId(targetVertexId);
82 }
8384public E getEdgeValue() {
85return edge.getValue();
86 }
8788/**89 * Set the value of this edge90 *91 * @param value Edge value92 */93publicvoid setEdgeValue(E value) {
94 edge.setValue(value);
95 }
96 }