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 */18package org.apache.giraph.factories;
1920importstatic org.apache.giraph.conf.GiraphConstants.EDGE_VALUE_FACTORY_CLASS;
21importstatic org.apache.giraph.conf.GiraphConstants.VERTEX_ID_FACTORY_CLASS;
22importstatic org.apache.giraph.conf.GiraphConstants.VERTEX_VALUE_FACTORY_CLASS;
2324import org.apache.hadoop.conf.Configuration;
25import org.apache.hadoop.io.Writable;
26import org.apache.hadoop.io.WritableComparable;
2728/**29 * Holder for factories to create user types.30 *31 * Note that we don't store the {@link MessageValueFactory} here because they32 * reference types which may change at a given superstep. Instead we create them33 * as necessary so that they get the latest information.34 *35 * @param <I> Vertex id36 * @param <V> Vertex data37 * @param <E> Edge data38 */39publicclass ValueFactories<I extends WritableComparable,
40 V extends Writable, E extends Writable> {
41/** Vertex ID factory. */42privatefinal VertexIdFactory<I> vertexIdFactory;
43/** Vertex value factory. */44privatefinal VertexValueFactory<V> vertexValueFactory;
45/** Edge value factory. */46privatefinal EdgeValueFactory<E> edgeValueFactory;
4748/**49 * Constructor reading from Configuration50 *51 * @param conf Configuration to read from52 */53publicValueFactories(Configuration conf) {
54 vertexIdFactory = VERTEX_ID_FACTORY_CLASS.newInstance(conf);
55 vertexValueFactory = VERTEX_VALUE_FACTORY_CLASS.newInstance(conf);
56 edgeValueFactory = EDGE_VALUE_FACTORY_CLASS.newInstance(conf);
57 }
5859public EdgeValueFactory<E> getEdgeValueFactory() {
60return edgeValueFactory;
61 }
6263public VertexIdFactory<I> getVertexIdFactory() {
64return vertexIdFactory;
65 }
6667public VertexValueFactory<V> getVertexValueFactory() {
68return vertexValueFactory;
69 }
70 }