1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
package org.apache.giraph.graph; |
19 | |
|
20 | |
import org.apache.giraph.conf.ClassConfOption; |
21 | |
import org.apache.giraph.conf.GiraphConstants; |
22 | |
import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration; |
23 | |
import org.apache.giraph.factories.ValueFactory; |
24 | |
import org.apache.hadoop.conf.Configuration; |
25 | |
import org.apache.hadoop.io.Writable; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | 0 | public enum GraphType { |
31 | |
|
32 | 0 | VERTEX_ID { |
33 | |
@Override |
34 | |
public ClassConfOption<? extends Writable> writableConfOption() { |
35 | 0 | return GiraphConstants.VERTEX_ID_CLASS; |
36 | |
} |
37 | |
@Override |
38 | |
public ClassConfOption<? extends ValueFactory> factoryClassOption() { |
39 | 0 | return GiraphConstants.VERTEX_ID_FACTORY_CLASS; |
40 | |
} |
41 | |
@Override |
42 | |
public <T extends Writable> Class<T> get( |
43 | |
ImmutableClassesGiraphConfiguration conf) { |
44 | 0 | return conf.getVertexIdClass(); |
45 | |
} |
46 | |
@Override |
47 | |
public <T extends Writable> ValueFactory<T> factory( |
48 | |
ImmutableClassesGiraphConfiguration conf) { |
49 | 0 | return conf.getVertexIdFactory(); |
50 | |
} |
51 | |
}, |
52 | |
|
53 | 0 | VERTEX_VALUE { |
54 | |
@Override public ClassConfOption<? extends Writable> writableConfOption() { |
55 | 0 | return GiraphConstants.VERTEX_VALUE_CLASS; |
56 | |
} |
57 | |
@Override |
58 | |
public ClassConfOption<? extends ValueFactory> factoryClassOption() { |
59 | 0 | return GiraphConstants.VERTEX_VALUE_FACTORY_CLASS; |
60 | |
} |
61 | |
@Override |
62 | |
public <T extends Writable> Class<T> get( |
63 | |
ImmutableClassesGiraphConfiguration conf) { |
64 | 0 | return conf.getVertexValueClass(); |
65 | |
} |
66 | |
@Override |
67 | |
public <T extends Writable> ValueFactory<T> factory( |
68 | |
ImmutableClassesGiraphConfiguration conf) { |
69 | 0 | return conf.getVertexValueFactory(); |
70 | |
} |
71 | |
}, |
72 | |
|
73 | 0 | EDGE_VALUE { |
74 | |
@Override |
75 | |
public ClassConfOption<? extends Writable> writableConfOption() { |
76 | 0 | return GiraphConstants.EDGE_VALUE_CLASS; |
77 | |
} |
78 | |
@Override |
79 | |
public ClassConfOption<? extends ValueFactory> factoryClassOption() { |
80 | 0 | return GiraphConstants.EDGE_VALUE_FACTORY_CLASS; |
81 | |
} |
82 | |
@Override |
83 | |
public <T extends Writable> Class<T> get( |
84 | |
ImmutableClassesGiraphConfiguration conf) { |
85 | 0 | return conf.getEdgeValueClass(); |
86 | |
} |
87 | |
@Override |
88 | |
public <T extends Writable> ValueFactory<T> factory( |
89 | |
ImmutableClassesGiraphConfiguration conf) { |
90 | 0 | return conf.getEdgeValueFactory(); |
91 | |
} |
92 | |
}, |
93 | |
|
94 | 0 | OUTGOING_MESSAGE_VALUE { |
95 | |
@Override |
96 | |
public ClassConfOption<? extends Writable> writableConfOption() { |
97 | 0 | return GiraphConstants.OUTGOING_MESSAGE_VALUE_CLASS; |
98 | |
} |
99 | |
@Override |
100 | |
public ClassConfOption<? extends ValueFactory> factoryClassOption() { |
101 | 0 | return GiraphConstants.OUTGOING_MESSAGE_VALUE_FACTORY_CLASS; |
102 | |
} |
103 | |
@Override |
104 | |
public <T extends Writable> Class<T> get( |
105 | |
ImmutableClassesGiraphConfiguration conf) { |
106 | 0 | return conf.getOutgoingMessageValueClass(); |
107 | |
} |
108 | |
@Override |
109 | |
public <T extends Writable> ValueFactory<T> factory( |
110 | |
ImmutableClassesGiraphConfiguration conf) { |
111 | 0 | return conf.createOutgoingMessageValueFactory(); |
112 | |
} |
113 | |
}; |
114 | |
|
115 | |
@Override |
116 | |
public String toString() { |
117 | 0 | return name().toLowerCase(); |
118 | |
} |
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
public String dotString() { |
126 | 0 | return toString().replaceAll("_", "."); |
127 | |
} |
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
public String spaceString() { |
135 | 0 | return toString().replaceAll("_", " "); |
136 | |
} |
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
public abstract <T extends Writable> Class<T> get( |
146 | |
ImmutableClassesGiraphConfiguration conf); |
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
public abstract <T extends Writable> ValueFactory<T> factory( |
156 | |
ImmutableClassesGiraphConfiguration conf); |
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
|
163 | |
|
164 | |
public abstract <T extends ValueFactory> ClassConfOption<T> |
165 | |
factoryClassOption(); |
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | |
public abstract <T extends Writable> ClassConfOption<T> writableConfOption(); |
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
|
180 | |
|
181 | |
public <T extends Writable> Class<T> interfaceClass() { |
182 | 0 | return this.<T>writableConfOption().getInterfaceClass(); |
183 | |
} |
184 | |
|
185 | |
|
186 | |
|
187 | |
|
188 | |
|
189 | |
|
190 | |
|
191 | |
|
192 | |
public <T extends Writable> Class<? extends T> get(Configuration conf) { |
193 | 0 | if (conf instanceof ImmutableClassesGiraphConfiguration) { |
194 | 0 | ImmutableClassesGiraphConfiguration icgc = |
195 | |
(ImmutableClassesGiraphConfiguration) conf; |
196 | 0 | return get(icgc); |
197 | |
} |
198 | 0 | return this.<T>writableConfOption().get(conf); |
199 | |
} |
200 | |
|
201 | |
|
202 | |
|
203 | |
|
204 | |
|
205 | |
|
206 | |
|
207 | |
|
208 | |
public <T extends Writable> T newInstance( |
209 | |
ImmutableClassesGiraphConfiguration conf) { |
210 | 0 | return (T) factory(conf).newInstance(); |
211 | |
} |
212 | |
} |