This project has retired. For details please refer to its Attic page.
PerGraphTypeBoolean xref
View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * 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 and
16   * limitations under the License.
17   */
18  package org.apache.giraph.conf;
19  
20  import org.apache.giraph.graph.GraphType;
21  import org.apache.hadoop.conf.Configuration;
22  
23  /**
24   * A boolean stored per user graph type
25   */
26  public class PerGraphTypeBoolean {
27    /** data for vertex id */
28    private boolean vertexId;
29    /** data for vertex value */
30    private boolean vertexValue;
31    /** data for edge value */
32    private boolean edgeValue;
33    /** data for outgoing message */
34    private boolean outgoingMessage;
35  
36    /**
37     * Create from options and configuration
38     *
39     * @param options pre user graph type options
40     * @param conf configuration
41     * @return new object
42     */
43    public static PerGraphTypeBoolean readFromConf(
44        PerGraphTypeBooleanConfOption options, Configuration conf) {
45      PerGraphTypeBoolean pgtb = new PerGraphTypeBoolean();
46      pgtb.setFrom(options, conf);
47      return pgtb;
48    }
49  
50    /**
51     * Set data from per user graph type set of options
52     *
53     * @param options per user graph type options
54     * @param conf Configuration
55     */
56    public void 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    }
63  
64    /**
65     * Set the vertex id data from the option
66     *
67     * @param option EnumConfOption option to use
68     * @param conf Configuration
69     */
70    public void setVertexId(BooleanConfOption option, Configuration conf) {
71      vertexId = option.get(conf);
72    }
73  
74    /**
75     * Set the vertex value data from the option
76     *
77     * @param option EnumConfOption option to use
78     * @param conf Configuration
79     */
80    public void setVertexValue(BooleanConfOption option, Configuration conf) {
81      vertexValue = option.get(conf);
82    }
83  
84    /**
85     * Set the edge value data from the option
86     *
87     * @param option EnumConfOption option to use
88     * @param conf Configuration
89     */
90    public void setEdgeValue(BooleanConfOption option, Configuration conf) {
91      edgeValue = option.get(conf);
92    }
93  
94    /**
95     * Set the outgoing message value data from the option
96     *
97     * @param option EnumConfOption option to use
98     * @param conf Configuration
99     */
100   public void setOutgoingMessage(BooleanConfOption option, Configuration conf) {
101     outgoingMessage = option.get(conf);
102   }
103 
104   /**
105    * Get data for given GraphType
106    *
107    * @param graphType GraphType
108    * @return data for given graph type
109    */
110   public boolean get(GraphType graphType) {
111     switch (graphType) {
112     case VERTEX_ID:
113       return vertexId;
114     case VERTEX_VALUE:
115       return vertexValue;
116     case EDGE_VALUE:
117       return edgeValue;
118     case OUTGOING_MESSAGE_VALUE:
119       return outgoingMessage;
120     default:
121       throw new IllegalArgumentException(
122           "Don't know how to handle GraphType " + graphType);
123     }
124   }
125 
126   public boolean getEdgeValue() {
127     return edgeValue;
128   }
129 
130   public boolean getOutgoingMessage() {
131     return outgoingMessage;
132   }
133 
134   public boolean getVertexId() {
135     return vertexId;
136   }
137 
138   public boolean getVertexValue() {
139     return vertexValue;
140   }
141 }