1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.giraph.edge; |
20 | |
|
21 | |
import org.apache.giraph.bsp.CentralizedServiceWorker; |
22 | |
import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration; |
23 | |
import org.apache.giraph.edge.primitives.IntEdgeStore; |
24 | |
import org.apache.giraph.edge.primitives.LongEdgeStore; |
25 | |
import org.apache.hadoop.io.IntWritable; |
26 | |
import org.apache.hadoop.io.LongWritable; |
27 | |
import org.apache.hadoop.io.Writable; |
28 | |
import org.apache.hadoop.io.WritableComparable; |
29 | |
import org.apache.hadoop.util.Progressable; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
@SuppressWarnings("unchecked") |
41 | 0 | public class InMemoryEdgeStoreFactory<I extends WritableComparable, |
42 | |
V extends Writable, E extends Writable> |
43 | |
implements EdgeStoreFactory<I, V, E> { |
44 | |
|
45 | |
protected CentralizedServiceWorker<I, V, E> service; |
46 | |
|
47 | |
protected ImmutableClassesGiraphConfiguration<I, V, E> conf; |
48 | |
|
49 | |
protected Progressable progressable; |
50 | |
|
51 | |
@Override |
52 | |
public EdgeStore<I, V, E> newStore() { |
53 | 0 | Class<I> vertexIdClass = conf.getVertexIdClass(); |
54 | |
EdgeStore<I, V, E> edgeStore; |
55 | 0 | if (vertexIdClass.equals(IntWritable.class)) { |
56 | 0 | edgeStore = (EdgeStore<I, V, E>) new IntEdgeStore<>( |
57 | |
(CentralizedServiceWorker<IntWritable, V, E>) service, |
58 | |
(ImmutableClassesGiraphConfiguration<IntWritable, V, E>) conf, |
59 | |
progressable); |
60 | 0 | } else if (vertexIdClass.equals(LongWritable.class)) { |
61 | 0 | edgeStore = (EdgeStore<I, V, E>) new LongEdgeStore<>( |
62 | |
(CentralizedServiceWorker<LongWritable, V, E>) service, |
63 | |
(ImmutableClassesGiraphConfiguration<LongWritable, V, E>) conf, |
64 | |
progressable); |
65 | |
} else { |
66 | 0 | edgeStore = new SimpleEdgeStore<>(service, conf, progressable); |
67 | |
} |
68 | 0 | return edgeStore; |
69 | |
} |
70 | |
|
71 | |
@Override |
72 | |
public void initialize(CentralizedServiceWorker<I, V, E> service, |
73 | |
ImmutableClassesGiraphConfiguration<I, V, E> conf, |
74 | |
Progressable progressable) { |
75 | 0 | this.service = service; |
76 | 0 | this.conf = conf; |
77 | 0 | this.progressable = progressable; |
78 | 0 | } |
79 | |
} |