Coverage Report - org.apache.giraph.conf.PerGraphTypeEnumConfOption
 
Classes in this File Line Coverage Branch Coverage Complexity
PerGraphTypeEnumConfOption
0%
0/19
0%
0/5
2.125
PerGraphTypeEnumConfOption$1
0%
0/1
N/A
2.125
 
 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  
  * Enum Configuration option per user graph type (IVEMM)
 25  
  *
 26  
  * @param <T> Enum class
 27  
  */
 28  
 public class PerGraphTypeEnumConfOption<T extends Enum<T>> {
 29  
   /** option for vertex id */
 30  
   private final EnumConfOption<T> vertexId;
 31  
   /** option for vertex value */
 32  
   private final EnumConfOption<T> vertexValue;
 33  
   /** option for edge value */
 34  
   private final EnumConfOption<T> edgeValue;
 35  
   /** option for outgoing message */
 36  
   private final EnumConfOption<T> outgoingMessage;
 37  
 
 38  
   /**
 39  
    * Constructor
 40  
    *
 41  
    * @param keyPrefix Configuration key prefix
 42  
    * @param klass Enum class
 43  
    * @param defaultValue default value
 44  
    * @param description description of the option
 45  
    */
 46  
   public PerGraphTypeEnumConfOption(String keyPrefix, Class<T> klass,
 47  0
       T defaultValue, String description) {
 48  0
     vertexId = EnumConfOption.create(keyPrefix + ".vertex.id", klass,
 49  
         defaultValue, description);
 50  0
     vertexValue = EnumConfOption.create(keyPrefix + ".vertex.value", klass,
 51  
         defaultValue, description);
 52  0
     edgeValue = EnumConfOption.create(keyPrefix + ".edge.value",
 53  
         klass, defaultValue, description);
 54  0
     outgoingMessage = EnumConfOption.create(keyPrefix + ".outgoing.message",
 55  
         klass, defaultValue, description);
 56  0
   }
 57  
 
 58  
   /**
 59  
    * Create new EnumGraphTypeConfOption
 60  
    *
 61  
    * @param keyPrefix String configuration key prefix
 62  
    * @param klass enum class
 63  
    * @param defaultValue default enum value
 64  
    * @param description description of the option
 65  
    * @param <X> enum type
 66  
    * @return EnumConfOption
 67  
    */
 68  
   public static <X extends Enum<X>> PerGraphTypeEnumConfOption<X>
 69  
   create(String keyPrefix, Class<X> klass, X defaultValue, String description) {
 70  0
     return new PerGraphTypeEnumConfOption<X>(keyPrefix, klass,
 71  
         defaultValue, description);
 72  
   }
 73  
 
 74  
   /**
 75  
    * Get option for given GraphType
 76  
    *
 77  
    * @param graphType GraphType
 78  
    * @return EnumConfOption for given graph type
 79  
    */
 80  
   public EnumConfOption<T> get(GraphType graphType) {
 81  0
     switch (graphType) {
 82  
     case VERTEX_ID:
 83  0
       return vertexId;
 84  
     case VERTEX_VALUE:
 85  0
       return vertexValue;
 86  
     case EDGE_VALUE:
 87  0
       return edgeValue;
 88  
     case OUTGOING_MESSAGE_VALUE:
 89  0
       return outgoingMessage;
 90  
     default:
 91  0
       throw new IllegalArgumentException(
 92  
           "Don't know how to handle GraphType " + graphType);
 93  
     }
 94  
   }
 95  
 
 96  
   /**
 97  
    * Set value for given GraphType
 98  
    *
 99  
    * @param conf Configuration
 100  
    * @param graphType GraphType
 101  
    * @param language Language
 102  
    */
 103  
   public void set(Configuration conf, GraphType graphType, T language) {
 104  0
     get(graphType).set(conf, language);
 105  0
   }
 106  
 
 107  
   public EnumConfOption<T> getEdgeValue() {
 108  0
     return edgeValue;
 109  
   }
 110  
 
 111  
   public EnumConfOption<T> getOutgoingMessage() {
 112  0
     return outgoingMessage;
 113  
   }
 114  
 
 115  
   public EnumConfOption<T> getVertexId() {
 116  0
     return vertexId;
 117  
   }
 118  
 
 119  
   public EnumConfOption<T> getVertexValue() {
 120  0
     return vertexValue;
 121  
   }
 122  
 }
 123