This project has retired. For details please refer to its
Attic page.
PerGraphTypeEnumConfOption xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
25
26
27
28 public class PerGraphTypeEnumConfOption<T extends Enum<T>> {
29
30 private final EnumConfOption<T> vertexId;
31
32 private final EnumConfOption<T> vertexValue;
33
34 private final EnumConfOption<T> edgeValue;
35
36 private final EnumConfOption<T> outgoingMessage;
37
38
39
40
41
42
43
44
45
46 public PerGraphTypeEnumConfOption(String keyPrefix, Class<T> klass,
47 T defaultValue, String description) {
48 vertexId = EnumConfOption.create(keyPrefix + ".vertex.id", klass,
49 defaultValue, description);
50 vertexValue = EnumConfOption.create(keyPrefix + ".vertex.value", klass,
51 defaultValue, description);
52 edgeValue = EnumConfOption.create(keyPrefix + ".edge.value",
53 klass, defaultValue, description);
54 outgoingMessage = EnumConfOption.create(keyPrefix + ".outgoing.message",
55 klass, defaultValue, description);
56 }
57
58
59
60
61
62
63
64
65
66
67
68 public static <X extends Enum<X>> PerGraphTypeEnumConfOption<X>
69 create(String keyPrefix, Class<X> klass, X defaultValue, String description) {
70 return new PerGraphTypeEnumConfOption<X>(keyPrefix, klass,
71 defaultValue, description);
72 }
73
74
75
76
77
78
79
80 public EnumConfOption<T> get(GraphType graphType) {
81 switch (graphType) {
82 case VERTEX_ID:
83 return vertexId;
84 case VERTEX_VALUE:
85 return vertexValue;
86 case EDGE_VALUE:
87 return edgeValue;
88 case OUTGOING_MESSAGE_VALUE:
89 return outgoingMessage;
90 default:
91 throw new IllegalArgumentException(
92 "Don't know how to handle GraphType " + graphType);
93 }
94 }
95
96
97
98
99
100
101
102
103 public void set(Configuration conf, GraphType graphType, T language) {
104 get(graphType).set(conf, language);
105 }
106
107 public EnumConfOption<T> getEdgeValue() {
108 return edgeValue;
109 }
110
111 public EnumConfOption<T> getOutgoingMessage() {
112 return outgoingMessage;
113 }
114
115 public EnumConfOption<T> getVertexId() {
116 return vertexId;
117 }
118
119 public EnumConfOption<T> getVertexValue() {
120 return vertexValue;
121 }
122 }
123