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 * A boolean stored per user graph type25 */26publicclassPerGraphTypeBoolean {
27/** data for vertex id */28privateboolean vertexId;
29/** data for vertex value */30privateboolean vertexValue;
31/** data for edge value */32privateboolean edgeValue;
33/** data for outgoing message */34privateboolean outgoingMessage;
3536/**37 * Create from options and configuration38 *39 * @param options pre user graph type options40 * @param conf configuration41 * @return new object42 */43publicstaticPerGraphTypeBoolean readFromConf(
44PerGraphTypeBooleanConfOption options, Configuration conf) {
45PerGraphTypeBoolean pgtb = newPerGraphTypeBoolean();
46 pgtb.setFrom(options, conf);
47return pgtb;
48 }
4950/**51 * Set data from per user graph type set of options52 *53 * @param options per user graph type options54 * @param conf Configuration55 */56publicvoid setFrom(PerGraphTypeBooleanConfOption options,
57 Configuration conf) {
58 setVertexId(options.getVertexId(), conf);
59 setVertexValue(options.getVertexValue(), conf);
60 setEdgeValue(options.getEdgeValue(), conf);
61 setOutgoingMessage(options.getOutgoingMessage(), conf);
62 }
6364/**65 * Set the vertex id data from the option66 *67 * @param option EnumConfOption option to use68 * @param conf Configuration69 */70publicvoid setVertexId(BooleanConfOption option, Configuration conf) {
71 vertexId = option.get(conf);
72 }
7374/**75 * Set the vertex value data from the option76 *77 * @param option EnumConfOption option to use78 * @param conf Configuration79 */80publicvoid setVertexValue(BooleanConfOption option, Configuration conf) {
81 vertexValue = option.get(conf);
82 }
8384/**85 * Set the edge value data from the option86 *87 * @param option EnumConfOption option to use88 * @param conf Configuration89 */90publicvoid setEdgeValue(BooleanConfOption option, Configuration conf) {
91 edgeValue = option.get(conf);
92 }
9394/**95 * Set the outgoing message value data from the option96 *97 * @param option EnumConfOption option to use98 * @param conf Configuration99 */100publicvoid setOutgoingMessage(BooleanConfOption option, Configuration conf) {
101 outgoingMessage = option.get(conf);
102 }
103104/**105 * Get data for given GraphType106 *107 * @param graphType GraphType108 * @return data for given graph type109 */110publicboolean get(GraphType graphType) {
111switch (graphType) {
112case VERTEX_ID:
113return vertexId;
114case VERTEX_VALUE:
115return vertexValue;
116case EDGE_VALUE:
117return edgeValue;
118case OUTGOING_MESSAGE_VALUE:
119return outgoingMessage;
120default:
121thrownew IllegalArgumentException(
122"Don't know how to handle GraphType " + graphType);
123 }
124 }
125126publicboolean getEdgeValue() {
127return edgeValue;
128 }
129130publicboolean getOutgoingMessage() {
131return outgoingMessage;
132 }
133134publicboolean getVertexId() {
135return vertexId;
136 }
137138publicboolean getVertexValue() {
139return vertexValue;
140 }
141 }