This project has retired. For details please refer to its Attic page.
JythonOptions 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.jython;
19  
20  import org.apache.giraph.conf.BooleanConfOption;
21  import org.apache.giraph.conf.EnumConfOption;
22  import org.apache.giraph.conf.StrConfOption;
23  import org.apache.giraph.graph.GraphType;
24  import org.apache.giraph.graph.Language;
25  
26  /**
27   * Jython related {@link org.apache.hadoop.conf.Configuration} options
28   */
29  public class JythonOptions {
30    /** Options for a graph type */
31    public static class JythonGraphTypeOptions {
32      /** user graph type */
33      private final GraphType graphType;
34      /** Option for Jython class name implementing type */
35      private final StrConfOption jythonClassNameOption;
36      /** Option for whether Jython type needs a wrapper */
37      private final BooleanConfOption needsWrapperOption;
38      /** Option for language */
39      private final EnumConfOption<Language> languageOption;
40  
41      /**
42       * Constructor
43       *
44       * @param graphType GraphType
45       */
46      public JythonGraphTypeOptions(GraphType graphType) {
47        this.graphType = graphType;
48        jythonClassNameOption = new StrConfOption("giraph.jython." +
49            graphType.dotString() + ".class.name", null,
50            "Name of class in Jython implementing " + graphType.spaceString());
51        needsWrapperOption = new BooleanConfOption("giraph.jython." +
52            graphType.dotString() + ".needs.wrapper", false,
53            "Whether the " + graphType.spaceString() +
54            " jython type needs a wrapper");
55        languageOption = EnumConfOption.create("giraph." +
56            graphType.dotString() + ".language", Language.class, Language.JAVA,
57            "Language " + graphType.spaceString() + " is implemented in");
58      }
59  
60      public GraphType getGraphType() {
61        return graphType;
62      }
63  
64      public BooleanConfOption getNeedsWrapperOption() {
65        return needsWrapperOption;
66      }
67  
68      public StrConfOption getJythonClassNameOption() {
69        return jythonClassNameOption;
70      }
71  
72      private EnumConfOption<Language> getLanguageOption() {
73        return languageOption;
74      }
75    }
76  
77    /** vertex id options */
78    public static final JythonGraphTypeOptions JYTHON_VERTEX_ID =
79        new JythonGraphTypeOptions(GraphType.VERTEX_ID);
80  
81    /** vertex value options */
82    public static final JythonGraphTypeOptions JYTHON_VERTEX_VALUE =
83        new JythonGraphTypeOptions(GraphType.VERTEX_VALUE);
84  
85    /** edge value options */
86    public static final JythonGraphTypeOptions JYTHON_EDGE_VALUE =
87        new JythonGraphTypeOptions(GraphType.EDGE_VALUE);
88  
89    /** outgonig message value options */
90    public static final JythonGraphTypeOptions JYTHON_OUT_MSG_VALUE =
91        new JythonGraphTypeOptions(GraphType.OUTGOING_MESSAGE_VALUE);
92  
93    /** Name of Computation class in Jython script */
94    public static final StrConfOption JYTHON_COMPUTATION_CLASS_NAME =
95        new StrConfOption("giraph.jython.class", null,
96            "Name of Computation class in Jython script");
97  
98    /** Don't construct */
99    private JythonOptions() { }
100 }