This project has retired. For details please refer to its
Attic page.
GiraphClasses 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.aggregators.AggregatorWriter;
21 import org.apache.giraph.aggregators.TextAggregatorWriter;
22 import org.apache.giraph.comm.messages.MessageEncodeAndStoreType;
23 import org.apache.giraph.edge.ByteArrayEdges;
24 import org.apache.giraph.edge.OutEdges;
25 import org.apache.giraph.factories.ComputationFactory;
26 import org.apache.giraph.factories.DefaultComputationFactory;
27 import org.apache.giraph.factories.DefaultMessageValueFactory;
28 import org.apache.giraph.graph.Computation;
29 import org.apache.giraph.graph.DefaultVertexResolver;
30 import org.apache.giraph.graph.DefaultVertexValueCombiner;
31 import org.apache.giraph.graph.Vertex;
32 import org.apache.giraph.graph.VertexResolver;
33 import org.apache.giraph.graph.VertexValueCombiner;
34 import org.apache.giraph.io.EdgeInputFormat;
35 import org.apache.giraph.io.EdgeOutputFormat;
36 import org.apache.giraph.io.MappingInputFormat;
37 import org.apache.giraph.io.VertexInputFormat;
38 import org.apache.giraph.io.VertexOutputFormat;
39 import org.apache.giraph.io.filters.DefaultEdgeInputFilter;
40 import org.apache.giraph.io.filters.DefaultVertexInputFilter;
41 import org.apache.giraph.io.filters.EdgeInputFilter;
42 import org.apache.giraph.io.filters.VertexInputFilter;
43 import org.apache.giraph.master.DefaultMasterCompute;
44 import org.apache.giraph.master.MasterCompute;
45 import org.apache.giraph.partition.GraphPartitionerFactory;
46 import org.apache.giraph.partition.HashPartitionerFactory;
47 import org.apache.giraph.partition.Partition;
48 import org.apache.giraph.partition.SimplePartition;
49 import org.apache.giraph.types.NoMessage;
50 import org.apache.giraph.worker.DefaultWorkerContext;
51 import org.apache.giraph.worker.WorkerContext;
52 import org.apache.hadoop.conf.Configuration;
53 import org.apache.hadoop.io.Writable;
54 import org.apache.hadoop.io.WritableComparable;
55
56
57
58
59
60
61
62
63 @SuppressWarnings("unchecked")
64 public class GiraphClasses<I extends WritableComparable,
65 V extends Writable, E extends Writable>
66 implements GiraphConstants {
67
68 protected Class<? extends ComputationFactory<I, V, E,
69 ? extends Writable, ? extends Writable>>
70 computationFactoryClass;
71
72 protected Class<? extends Computation<I, V, E,
73 ? extends Writable, ? extends Writable>>
74 computationClass;
75
76 protected GiraphTypes<I, V, E> giraphTypes;
77
78 protected Class<? extends OutEdges<I, E>> outEdgesClass;
79
80 protected Class<? extends OutEdges<I, E>> inputOutEdgesClass;
81
82
83 protected Class<? extends GraphPartitionerFactory<I, V, E>>
84 graphPartitionerFactoryClass;
85
86
87 protected Class<? extends VertexInputFormat<I, V, E>>
88 vertexInputFormatClass;
89
90 protected Class<? extends VertexOutputFormat<I, V, E>>
91 vertexOutputFormatClass;
92
93 protected Class<? extends MappingInputFormat<I, V, E, ? extends Writable>>
94 mappingInputFormatClass;
95
96 protected Class<? extends EdgeInputFormat<I, E>>
97 edgeInputFormatClass;
98
99 protected Class<? extends EdgeOutputFormat<I, V, E>>
100 edgeOutputFormatClass;
101
102
103 protected Class<? extends AggregatorWriter> aggregatorWriterClass;
104
105
106 protected MessageClasses<I, ? extends Writable> incomingMessageClasses;
107
108 protected MessageClasses<I, ? extends Writable> outgoingMessageClasses;
109
110
111 protected Class<? extends VertexResolver<I, V, E>> vertexResolverClass;
112
113 protected Class<? extends VertexValueCombiner<V>> vertexValueCombinerClass;
114
115 protected Class<? extends WorkerContext> workerContextClass;
116
117 protected Class<? extends MasterCompute> masterComputeClass;
118
119
120 protected Class<? extends Partition<I, V, E>> partitionClass;
121
122
123 protected Class<? extends EdgeInputFilter<I, E>> edgeInputFilterClass;
124
125 protected Class<? extends VertexInputFilter<I, V, E>> vertexInputFilterClass;
126
127
128
129
130 public GiraphClasses() {
131 computationFactoryClass = (Class) DefaultComputationFactory.class;
132 giraphTypes = new GiraphTypes<I, V, E>();
133 outEdgesClass = (Class) ByteArrayEdges.class;
134 inputOutEdgesClass = (Class) ByteArrayEdges.class;
135 graphPartitionerFactoryClass = (Class) HashPartitionerFactory.class;
136 aggregatorWriterClass = TextAggregatorWriter.class;
137 vertexResolverClass = (Class) DefaultVertexResolver.class;
138 vertexValueCombinerClass = (Class) DefaultVertexValueCombiner.class;
139 workerContextClass = DefaultWorkerContext.class;
140 masterComputeClass = DefaultMasterCompute.class;
141 partitionClass = (Class) SimplePartition.class;
142 edgeInputFilterClass = (Class) DefaultEdgeInputFilter.class;
143 vertexInputFilterClass = (Class) DefaultVertexInputFilter.class;
144 }
145
146
147
148
149
150
151 public GiraphClasses(Configuration conf) {
152 giraphTypes = GiraphTypes.readFrom(conf);
153 computationFactoryClass =
154 (Class<? extends ComputationFactory<I, V, E,
155 ? extends Writable, ? extends Writable>>)
156 COMPUTATION_FACTORY_CLASS.get(conf);
157 computationClass =
158 (Class<? extends Computation<I, V, E,
159 ? extends Writable, ? extends Writable>>)
160 COMPUTATION_CLASS.get(conf);
161
162 outEdgesClass = (Class<? extends OutEdges<I, E>>)
163 VERTEX_EDGES_CLASS.get(conf);
164 inputOutEdgesClass = (Class<? extends OutEdges<I, E>>)
165 INPUT_VERTEX_EDGES_CLASS.getWithDefault(conf, outEdgesClass);
166
167 graphPartitionerFactoryClass =
168 (Class<? extends GraphPartitionerFactory<I, V, E>>)
169 GRAPH_PARTITIONER_FACTORY_CLASS.get(conf);
170
171 vertexInputFormatClass = (Class<? extends VertexInputFormat<I, V, E>>)
172 VERTEX_INPUT_FORMAT_CLASS.get(conf);
173 vertexOutputFormatClass = (Class<? extends VertexOutputFormat<I, V, E>>)
174 VERTEX_OUTPUT_FORMAT_CLASS.get(conf);
175 edgeInputFormatClass = (Class<? extends EdgeInputFormat<I, E>>)
176 EDGE_INPUT_FORMAT_CLASS.get(conf);
177 edgeOutputFormatClass = (Class<? extends EdgeOutputFormat<I, V, E>>)
178 EDGE_OUTPUT_FORMAT_CLASS.get(conf);
179 mappingInputFormatClass = (Class<? extends MappingInputFormat<I, V, E,
180 ? extends Writable>>)
181 MAPPING_INPUT_FORMAT_CLASS.get(conf);
182
183 aggregatorWriterClass = AGGREGATOR_WRITER_CLASS.get(conf);
184
185
186
187
188 incomingMessageClasses = new DefaultMessageClasses(
189 NoMessage.class,
190 DefaultMessageValueFactory.class,
191 null,
192 MessageEncodeAndStoreType.BYTEARRAY_PER_PARTITION);
193 outgoingMessageClasses = new DefaultMessageClasses(
194 giraphTypes.getInitialOutgoingMessageValueClass(),
195 OUTGOING_MESSAGE_VALUE_FACTORY_CLASS.get(conf),
196 MESSAGE_COMBINER_CLASS.get(conf),
197 MESSAGE_ENCODE_AND_STORE_TYPE.get(conf));
198
199 vertexResolverClass = (Class<? extends VertexResolver<I, V, E>>)
200 VERTEX_RESOLVER_CLASS.get(conf);
201 vertexValueCombinerClass = (Class<? extends VertexValueCombiner<V>>)
202 VERTEX_VALUE_COMBINER_CLASS.get(conf);
203 workerContextClass = WORKER_CONTEXT_CLASS.get(conf);
204 masterComputeClass = MASTER_COMPUTE_CLASS.get(conf);
205 partitionClass = (Class<? extends Partition<I, V, E>>)
206 PARTITION_CLASS.get(conf);
207
208 edgeInputFilterClass = (Class<? extends EdgeInputFilter<I, E>>)
209 EDGE_INPUT_FILTER_CLASS.get(conf);
210 vertexInputFilterClass = (Class<? extends VertexInputFilter<I, V, E>>)
211 VERTEX_INPUT_FILTER_CLASS.get(conf);
212 }
213
214 public Class<? extends ComputationFactory<I, V, E,
215 ? extends Writable, ? extends Writable>> getComputationFactoryClass() {
216 return computationFactoryClass;
217 }
218
219
220
221
222
223
224 public Class<? extends Computation<I, V, E,
225 ? extends Writable, ? extends Writable>>
226 getComputationClass() {
227 return computationClass;
228 }
229
230 public GiraphTypes<I, V, E> getGiraphTypes() {
231 return giraphTypes;
232 }
233
234
235
236
237
238
239 public Class<I> getVertexIdClass() {
240 return giraphTypes.getVertexIdClass();
241 }
242
243
244
245
246
247
248
249 public Class<? extends Vertex> getVertexClass() {
250 return giraphTypes.getVertexClass();
251 }
252
253
254
255
256
257
258
259 public Class<V> getVertexValueClass() {
260 return giraphTypes.getVertexValueClass();
261 }
262
263
264
265
266
267
268 public Class<E> getEdgeValueClass() {
269 return giraphTypes.getEdgeValueClass();
270 }
271
272
273 public MessageClasses<? extends WritableComparable, ? extends Writable>
274 getIncomingMessageClasses() {
275 return incomingMessageClasses;
276 }
277
278 public MessageClasses<? extends WritableComparable, ? extends Writable>
279 getOutgoingMessageClasses() {
280 return outgoingMessageClasses;
281 }
282
283
284
285
286
287
288 public Class<? extends OutEdges<I, E>> getOutEdgesClass() {
289 return outEdgesClass;
290 }
291
292
293
294
295
296
297 public Class<? extends OutEdges<I, E>> getInputOutEdgesClass() {
298 return inputOutEdgesClass;
299 }
300
301
302
303
304
305
306 public Class<? extends GraphPartitionerFactory<I, V, E>>
307 getGraphPartitionerFactoryClass() {
308 return graphPartitionerFactoryClass;
309 }
310
311 public Class<? extends EdgeInputFilter<I, E>>
312 getEdgeInputFilterClass() {
313 return edgeInputFilterClass;
314 }
315
316 public Class<? extends VertexInputFilter<I, V, E>>
317 getVertexInputFilterClass() {
318 return vertexInputFilterClass;
319 }
320
321
322
323
324
325
326 public boolean hasVertexInputFormat() {
327 return vertexInputFormatClass != null;
328 }
329
330
331
332
333
334
335 public Class<? extends VertexInputFormat<I, V, E>>
336 getVertexInputFormatClass() {
337 return vertexInputFormatClass;
338 }
339
340
341
342
343
344
345 public boolean hasVertexOutputFormat() {
346 return vertexOutputFormatClass != null;
347 }
348
349
350
351
352
353
354 public boolean hasMappingInputFormat() {
355 return mappingInputFormatClass != null;
356 }
357
358
359
360
361
362
363 public Class<? extends VertexOutputFormat<I, V, E>>
364 getVertexOutputFormatClass() {
365 return vertexOutputFormatClass;
366 }
367
368 public Class<? extends MappingInputFormat<I, V, E, ? extends Writable>>
369 getMappingInputFormatClass() {
370 return mappingInputFormatClass;
371 }
372
373
374
375
376
377
378 public boolean hasEdgeInputFormat() {
379 return edgeInputFormatClass != null;
380 }
381
382
383
384
385
386
387 public Class<? extends EdgeInputFormat<I, E>> getEdgeInputFormatClass() {
388 return edgeInputFormatClass;
389 }
390
391
392
393
394
395
396 public boolean hasEdgeOutputFormat() {
397 return edgeOutputFormatClass != null;
398 }
399
400
401
402
403
404
405 public Class<? extends EdgeOutputFormat<I, V, E>>
406 getEdgeOutputFormatClass() {
407 return edgeOutputFormatClass;
408 }
409
410
411
412
413
414
415 public boolean hasAggregatorWriterClass() {
416 return aggregatorWriterClass != null;
417 }
418
419
420
421
422
423
424 public Class<? extends AggregatorWriter> getAggregatorWriterClass() {
425 return aggregatorWriterClass;
426 }
427
428
429
430
431
432
433 public boolean hasVertexResolverClass() {
434 return vertexResolverClass != null;
435 }
436
437
438
439
440
441
442 public Class<? extends VertexResolver<I, V, E>> getVertexResolverClass() {
443 return vertexResolverClass;
444 }
445
446
447
448
449
450
451 public Class<? extends VertexValueCombiner<V>> getVertexValueCombinerClass() {
452 return vertexValueCombinerClass;
453 }
454
455
456
457
458
459
460 public boolean hasWorkerContextClass() {
461 return workerContextClass != null;
462 }
463
464
465
466
467
468
469 public Class<? extends WorkerContext> getWorkerContextClass() {
470 return workerContextClass;
471 }
472
473
474
475
476
477
478 public boolean hasMasterComputeClass() {
479 return masterComputeClass != null;
480 }
481
482
483
484
485
486
487 public Class<? extends MasterCompute> getMasterComputeClass() {
488 return masterComputeClass;
489 }
490
491
492
493
494
495
496 public boolean hasPartitionClass() {
497 return partitionClass != null;
498 }
499
500
501
502
503
504
505 public Class<? extends Partition<I, V, E>> getPartitionClass() {
506 return partitionClass;
507 }
508
509
510
511
512
513
514
515 public GiraphClasses setComputationClass(Class<? extends
516 Computation<I, V, E, ? extends Writable, ? extends Writable>>
517 computationClass) {
518 this.computationClass = computationClass;
519 return this;
520 }
521
522
523
524
525
526
527
528 public GiraphClasses setVertexIdClass(Class<I> vertexIdClass) {
529 giraphTypes.setVertexIdClass(vertexIdClass);
530 return this;
531 }
532
533
534
535
536
537
538
539 public GiraphClasses setVertexValueClass(Class<V> vertexValueClass) {
540 giraphTypes.setVertexValueClass(vertexValueClass);
541 return this;
542 }
543
544
545
546
547
548
549
550 public GiraphClasses setEdgeValueClass(Class<E> edgeValueClass) {
551 giraphTypes.setEdgeValueClass(edgeValueClass);
552 return this;
553 }
554
555
556
557
558
559
560
561
562 public GiraphClasses setIncomingMessageClasses(
563 MessageClasses<I, ? extends Writable> incomingMessageClasses) {
564 this.incomingMessageClasses = incomingMessageClasses;
565 return this;
566 }
567
568
569
570
571
572
573
574
575 public GiraphClasses setOutgoingMessageClasses(
576 MessageClasses<I, ? extends Writable> outgoingMessageClasses) {
577 this.outgoingMessageClasses = outgoingMessageClasses;
578 return this;
579 }
580
581
582
583
584
585
586
587 public GiraphClasses setOutEdgesClass(
588 Class<? extends OutEdges> outEdgesClass) {
589 this.outEdgesClass =
590 (Class<? extends OutEdges<I, E>>) outEdgesClass;
591 return this;
592 }
593
594
595
596
597
598
599
600
601 public GiraphClasses setInputOutEdgesClass(
602 Class<? extends OutEdges> inputOutEdgesClass) {
603 this.inputOutEdgesClass =
604 (Class<? extends OutEdges<I, E>>) inputOutEdgesClass;
605 return this;
606 }
607
608
609
610
611
612
613
614 public GiraphClasses setGraphPartitionerFactoryClass(
615 Class<? extends GraphPartitionerFactory<I, V, E>> klass) {
616 this.graphPartitionerFactoryClass = klass;
617 return this;
618 }
619
620
621
622
623
624
625
626 public GiraphClasses setMappingInputFormatClass(
627 Class<? extends MappingInputFormat<I, V, E, Writable>>
628 mappingInputFormatClass) {
629 this.mappingInputFormatClass = mappingInputFormatClass;
630 return this;
631 }
632
633
634
635
636
637
638
639 public GiraphClasses setVertexInputFormatClass(
640 Class<? extends VertexInputFormat<I, V, E>> vertexInputFormatClass) {
641 this.vertexInputFormatClass = vertexInputFormatClass;
642 return this;
643 }
644
645
646
647
648
649
650
651 public GiraphClasses setVertexOutputFormatClass(
652 Class<? extends VertexOutputFormat<I, V, E>> vertexOutputFormatClass) {
653 this.vertexOutputFormatClass = vertexOutputFormatClass;
654 return this;
655 }
656
657
658
659
660
661
662
663 public GiraphClasses setEdgeInputFormatClass(
664 Class<? extends EdgeInputFormat<I, E>> edgeInputFormatClass) {
665 this.edgeInputFormatClass = edgeInputFormatClass;
666 return this;
667 }
668
669
670
671
672
673
674
675 public GiraphClasses setAggregatorWriterClass(
676 Class<? extends AggregatorWriter> aggregatorWriterClass) {
677 this.aggregatorWriterClass = aggregatorWriterClass;
678 return this;
679 }
680
681
682
683
684
685
686
687 public GiraphClasses setVertexResolverClass(
688 Class<? extends VertexResolver<I, V, E>> vertexResolverClass) {
689 this.vertexResolverClass = vertexResolverClass;
690 return this;
691 }
692
693
694
695
696
697
698
699 public GiraphClasses setWorkerContextClass(
700 Class<? extends WorkerContext> workerContextClass) {
701 this.workerContextClass = workerContextClass;
702 return this;
703 }
704
705
706
707
708
709
710
711 public GiraphClasses setMasterComputeClass(
712 Class<? extends MasterCompute> masterComputeClass) {
713 this.masterComputeClass = masterComputeClass;
714 return this;
715 }
716
717
718
719
720
721
722
723 public GiraphClasses setPartitionClass(
724 Class<? extends Partition<I, V, E>> partitionClass) {
725 this.partitionClass = partitionClass;
726 return this;
727 }
728 }