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.utils;
2021import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
22import org.apache.giraph.edge.Edge;
23import org.apache.hadoop.io.Writable;
24import org.apache.hadoop.io.WritableComparable;
2526import java.io.IOException;
2728/**29 * Stores vertex id and edge pairs in a single byte array.30 *31 * @param <I> Vertex id32 * @param <E> Edge value33 */34 @SuppressWarnings("unchecked")
35publicclass ByteArrayVertexIdEdges<I extends WritableComparable,
36 E extends Writable> extends ByteArrayVertexIdData<I, Edge<I,
37 E>> implements VertexIdEdges<I, E> {
38/**39 * Cast the {@link ImmutableClassesGiraphConfiguration} so it can be used40 * to generate edge objects.41 *42 * @return Casted configuration43 */44 @Override
45public ImmutableClassesGiraphConfiguration<I, ?, E> getConf() {
46return (ImmutableClassesGiraphConfiguration<I, ?, E>) super.getConf();
47 }
4849 @Override
50public Edge<I, E> createData() {
51return getConf().createReusableEdge();
52 }
5354 @Override
55publicvoid writeData(ExtendedDataOutput out, Edge<I, E> edge)
56throws IOException {
57 WritableUtils.writeEdge(out, edge);
58 }
5960 @Override
61publicvoid readData(ExtendedDataInput in, Edge<I, E> edge)
62throws IOException {
63 WritableUtils.readEdge(in, edge);
64 }
6566 @Override
67public ByteStructVertexIdEdgeIterator<I, E> getVertexIdEdgeIterator() {
68returnnew ByteStructVertexIdEdgeIterator<>(this);
69 }
70 }
71