1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
package org.apache.giraph.jython; |
19 | |
|
20 | |
import com.google.common.base.MoreObjects; |
21 | |
import org.apache.giraph.combiner.MessageCombiner; |
22 | |
|
23 | |
import com.google.common.collect.Lists; |
24 | |
import com.google.common.collect.Maps; |
25 | |
|
26 | |
import java.util.List; |
27 | |
import java.util.Map; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
public class JythonJob { |
37 | |
|
38 | |
|
39 | |
|
40 | 0 | public static class InputBase { |
41 | |
|
42 | |
private String table; |
43 | |
|
44 | |
private String partition_filter; |
45 | |
|
46 | |
public String getPartition_filter() { |
47 | 0 | return partition_filter; |
48 | |
} |
49 | |
|
50 | |
public void setPartition_filter(String partition_filter) { |
51 | 0 | this.partition_filter = partition_filter; |
52 | 0 | } |
53 | |
|
54 | |
public String getTable() { |
55 | 0 | return table; |
56 | |
} |
57 | |
|
58 | |
public void setTable(String table) { |
59 | 0 | this.table = table; |
60 | 0 | } |
61 | |
|
62 | |
@Override public String toString() { |
63 | 0 | return MoreObjects.toStringHelper(this) |
64 | 0 | .add("table", table) |
65 | 0 | .add("partition_filter", partition_filter) |
66 | 0 | .toString(); |
67 | |
} |
68 | |
} |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | 0 | public static class VertexInput extends InputBase { |
74 | |
|
75 | |
private String id_column; |
76 | |
|
77 | |
private String value_column; |
78 | |
|
79 | |
public String getId_column() { |
80 | 0 | return id_column; |
81 | |
} |
82 | |
|
83 | |
public void setId_column(String id_column) { |
84 | 0 | this.id_column = id_column; |
85 | 0 | } |
86 | |
|
87 | |
public String getValue_column() { |
88 | 0 | return value_column; |
89 | |
} |
90 | |
|
91 | |
public void setValue_column(String value_column) { |
92 | 0 | this.value_column = value_column; |
93 | 0 | } |
94 | |
|
95 | |
@Override public String toString() { |
96 | 0 | return MoreObjects.toStringHelper(this) |
97 | 0 | .add("table", getTable()) |
98 | 0 | .add("partition_filter", getPartition_filter()) |
99 | 0 | .add("id_column", id_column) |
100 | 0 | .add("value_column", value_column) |
101 | 0 | .toString(); |
102 | |
} |
103 | |
} |
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | 0 | public static class EdgeInput extends InputBase { |
109 | |
|
110 | |
private String source_id_column; |
111 | |
|
112 | |
private String target_id_column; |
113 | |
|
114 | |
private String value_column; |
115 | |
|
116 | |
public String getValue_column() { |
117 | 0 | return value_column; |
118 | |
} |
119 | |
|
120 | |
public void setValue_column(String value_column) { |
121 | 0 | this.value_column = value_column; |
122 | 0 | } |
123 | |
|
124 | |
public String getSource_id_column() { |
125 | 0 | return source_id_column; |
126 | |
} |
127 | |
|
128 | |
public void setSource_id_column(String source_id_column) { |
129 | 0 | this.source_id_column = source_id_column; |
130 | 0 | } |
131 | |
|
132 | |
public String getTarget_id_column() { |
133 | 0 | return target_id_column; |
134 | |
} |
135 | |
|
136 | |
public void setTarget_id_column(String target_id_column) { |
137 | 0 | this.target_id_column = target_id_column; |
138 | 0 | } |
139 | |
|
140 | |
@Override public String toString() { |
141 | 0 | return MoreObjects.toStringHelper(this) |
142 | 0 | .add("table", getTable()) |
143 | 0 | .add("partition_filter", getPartition_filter()) |
144 | 0 | .add("source_id_column", source_id_column) |
145 | 0 | .add("target_id_column", target_id_column) |
146 | 0 | .add("edge_value_column", value_column) |
147 | 0 | .toString(); |
148 | |
} |
149 | |
} |
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | 0 | public static class VertexOutput { |
155 | |
|
156 | |
private String table; |
157 | |
|
158 | 0 | private final Map<String, String> partition = Maps.newHashMap(); |
159 | |
|
160 | |
private String id_column; |
161 | |
|
162 | |
private String value_column; |
163 | |
|
164 | |
public String getId_column() { |
165 | 0 | return id_column; |
166 | |
} |
167 | |
|
168 | |
public void setId_column(String id_column) { |
169 | 0 | this.id_column = id_column; |
170 | 0 | } |
171 | |
|
172 | |
public Map<String, String> getPartition() { |
173 | 0 | return partition; |
174 | |
} |
175 | |
|
176 | |
public String getTable() { |
177 | 0 | return table; |
178 | |
} |
179 | |
|
180 | |
public void setTable(String table) { |
181 | 0 | this.table = table; |
182 | 0 | } |
183 | |
|
184 | |
public String getValue_column() { |
185 | 0 | return value_column; |
186 | |
} |
187 | |
|
188 | |
public void setValue_column(String value_column) { |
189 | 0 | this.value_column = value_column; |
190 | 0 | } |
191 | |
|
192 | |
@Override public String toString() { |
193 | 0 | return MoreObjects.toStringHelper(this) |
194 | 0 | .add("table", table) |
195 | 0 | .add("partition", partition) |
196 | 0 | .add("id_column", id_column) |
197 | 0 | .add("value_column", value_column) |
198 | 0 | .toString(); |
199 | |
} |
200 | |
} |
201 | |
|
202 | |
|
203 | |
|
204 | |
|
205 | 0 | public static class TypeHolder { |
206 | |
|
207 | |
|
208 | |
|
209 | |
|
210 | |
|
211 | |
|
212 | |
|
213 | |
|
214 | |
|
215 | |
private Object type; |
216 | |
|
217 | |
public Object getType() { |
218 | 0 | return type; |
219 | |
} |
220 | |
|
221 | |
public void setType(Object type) { |
222 | 0 | this.type = type; |
223 | 0 | } |
224 | |
} |
225 | |
|
226 | |
|
227 | |
|
228 | |
|
229 | 0 | public static class TypeWithHive extends TypeHolder { |
230 | |
|
231 | |
private Object hive_reader; |
232 | |
|
233 | |
private Object hive_writer; |
234 | |
|
235 | |
private Object hive_io; |
236 | |
|
237 | |
public Object getHive_io() { |
238 | 0 | return hive_io; |
239 | |
} |
240 | |
|
241 | |
public void setHive_io(Object hive_io) { |
242 | 0 | this.hive_io = hive_io; |
243 | 0 | } |
244 | |
|
245 | |
public Object getHive_reader() { |
246 | 0 | return hive_reader; |
247 | |
} |
248 | |
|
249 | |
public void setHive_reader(Object hive_reader) { |
250 | 0 | this.hive_reader = hive_reader; |
251 | 0 | } |
252 | |
|
253 | |
public Object getHive_writer() { |
254 | 0 | return hive_writer; |
255 | |
} |
256 | |
|
257 | |
public void setHive_writer(Object hive_writer) { |
258 | 0 | this.hive_writer = hive_writer; |
259 | 0 | } |
260 | |
} |
261 | |
|
262 | |
|
263 | |
private String name; |
264 | |
|
265 | 0 | private String hive_database = "digraph"; |
266 | |
|
267 | |
private int workers; |
268 | |
|
269 | |
private String pool; |
270 | |
|
271 | 0 | private final TypeWithHive vertex_id = new TypeWithHive(); |
272 | |
|
273 | 0 | private final TypeWithHive vertex_value = new TypeWithHive(); |
274 | |
|
275 | 0 | private final TypeWithHive edge_value = new TypeWithHive(); |
276 | |
|
277 | 0 | private final TypeHolder incoming_message_value = new TypeHolder(); |
278 | |
|
279 | 0 | private final TypeHolder outgoing_message_value = new TypeHolder(); |
280 | |
|
281 | 0 | private final TypeHolder message_value = new TypeHolder(); |
282 | |
|
283 | |
private String computation_name; |
284 | |
|
285 | |
private Class<? extends MessageCombiner> messageCombiner; |
286 | |
|
287 | 0 | private final List<String> java_options = Lists.newArrayList(); |
288 | |
|
289 | 0 | private final Map<String, Object> giraph_options = Maps.newHashMap(); |
290 | |
|
291 | 0 | private final List<VertexInput> vertex_inputs = Lists.newArrayList(); |
292 | |
|
293 | 0 | private final List<EdgeInput> edge_inputs = Lists.newArrayList(); |
294 | |
|
295 | 0 | private final VertexOutput vertex_output = new VertexOutput(); |
296 | |
|
297 | |
|
298 | |
|
299 | |
private String user; |
300 | |
|
301 | |
|
302 | |
|
303 | |
|
304 | 0 | public JythonJob() { |
305 | 0 | user = System.getProperty("user.name"); |
306 | 0 | workers = 5; |
307 | 0 | } |
308 | |
|
309 | |
public String getUser() { |
310 | 0 | return user; |
311 | |
} |
312 | |
|
313 | |
public TypeWithHive getVertex_value() { |
314 | 0 | return vertex_value; |
315 | |
} |
316 | |
|
317 | |
public TypeWithHive getVertex_id() { |
318 | 0 | return vertex_id; |
319 | |
} |
320 | |
|
321 | |
public TypeWithHive getEdge_value() { |
322 | 0 | return edge_value; |
323 | |
} |
324 | |
|
325 | |
public TypeHolder getIncoming_message_value() { |
326 | 0 | return incoming_message_value; |
327 | |
} |
328 | |
|
329 | |
public TypeHolder getOutgoing_message_value() { |
330 | 0 | return outgoing_message_value; |
331 | |
} |
332 | |
|
333 | |
public TypeHolder getMessage_value() { |
334 | 0 | return message_value; |
335 | |
} |
336 | |
|
337 | |
public List<String> getJava_options() { |
338 | 0 | return java_options; |
339 | |
} |
340 | |
|
341 | |
public Map<String, Object> getGiraph_options() { |
342 | 0 | return giraph_options; |
343 | |
} |
344 | |
|
345 | |
public Class<? extends MessageCombiner> getMessageCombiner() { |
346 | 0 | return messageCombiner; |
347 | |
} |
348 | |
|
349 | |
public void setMessageCombiner( |
350 | |
Class<? extends MessageCombiner> messageCombiner) { |
351 | 0 | this.messageCombiner = messageCombiner; |
352 | 0 | } |
353 | |
|
354 | |
public String getComputation_name() { |
355 | 0 | return computation_name; |
356 | |
} |
357 | |
|
358 | |
public void setComputation_name(String computation_name) { |
359 | 0 | this.computation_name = computation_name; |
360 | 0 | } |
361 | |
|
362 | |
public String getHive_database() { |
363 | 0 | return hive_database; |
364 | |
} |
365 | |
|
366 | |
public void setHive_database(String hive_database) { |
367 | 0 | this.hive_database = hive_database; |
368 | 0 | } |
369 | |
|
370 | |
public List<EdgeInput> getEdge_inputs() { |
371 | 0 | return edge_inputs; |
372 | |
} |
373 | |
|
374 | |
public String getName() { |
375 | 0 | return name; |
376 | |
} |
377 | |
|
378 | |
public void setName(String name) { |
379 | 0 | this.name = name; |
380 | 0 | } |
381 | |
|
382 | |
public String getPool() { |
383 | 0 | return pool; |
384 | |
} |
385 | |
|
386 | |
public void setPool(String pool) { |
387 | 0 | this.pool = pool; |
388 | 0 | } |
389 | |
|
390 | |
public List<VertexInput> getVertex_inputs() { |
391 | 0 | return vertex_inputs; |
392 | |
} |
393 | |
|
394 | |
public VertexOutput getVertex_output() { |
395 | 0 | return vertex_output; |
396 | |
} |
397 | |
|
398 | |
public int getWorkers() { |
399 | 0 | return workers; |
400 | |
} |
401 | |
|
402 | |
public void setWorkers(int workers) { |
403 | 0 | this.workers = workers; |
404 | 0 | } |
405 | |
} |
406 | |
|
407 | |
|
408 | |
|
409 | |
|