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.conf;
1920import org.apache.giraph.graph.GraphType;
21import org.apache.hadoop.conf.Configuration;
2223/**24 * Boolean Configuration option per user graph type (IVEMM)25 */26publicclassPerGraphTypeBooleanConfOption {
27/** option for vertex id */28privatefinalBooleanConfOption vertexId;
29/** option for vertex value */30privatefinalBooleanConfOption vertexValue;
31/** option for edge value */32privatefinalBooleanConfOption edgeValue;
33/** option for outgoing message */34privatefinalBooleanConfOption outgoingMessage;
3536/**37 * Constructor38 *39 * @param keyPrefix Configuration key prefix40 * @param defaultValue default value41 * @param description description of the option42 */43publicPerGraphTypeBooleanConfOption(String keyPrefix,
44boolean defaultValue, String description) {
45 vertexId = newBooleanConfOption(keyPrefix + ".vertex.id",
46 defaultValue, description);
47 vertexValue = newBooleanConfOption(keyPrefix + ".vertex.value",
48 defaultValue, description);
49 edgeValue = newBooleanConfOption(keyPrefix + ".edge.value",
50 defaultValue, description);
51 outgoingMessage = newBooleanConfOption(keyPrefix + ".outgoing.message",
52 defaultValue, description);
53 }
5455/**56 * Get option for given GraphType57 *58 * @param graphType GraphType59 * @return BooleanConfOption for given graph type60 */61publicBooleanConfOption get(GraphType graphType) {
62switch (graphType) {
63case VERTEX_ID:
64return vertexId;
65case VERTEX_VALUE:
66return vertexValue;
67case EDGE_VALUE:
68return edgeValue;
69case OUTGOING_MESSAGE_VALUE:
70return outgoingMessage;
71default:
72thrownew IllegalArgumentException(
73"Don't know how to handle GraphType " + graphType);
74 }
75 }
7677/**78 * Set value for given GraphType79 *80 * @param conf Configuration81 * @param graphType GraphType82 * @param value data83 */84publicvoid set(Configuration conf, GraphType graphType, boolean value) {
85 get(graphType).set(conf, value);
86 }
8788publicBooleanConfOption getEdgeValue() {
89return edgeValue;
90 }
9192publicBooleanConfOption getOutgoingMessage() {
93return outgoingMessage;
94 }
9596publicBooleanConfOption getVertexId() {
97return vertexId;
98 }
99100publicBooleanConfOption getVertexValue() {
101return vertexValue;
102 }
103 }
104