1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.giraph.mapping.translate; |
20 | |
|
21 | |
import org.apache.giraph.conf.DefaultImmutableClassesGiraphConfigurable; |
22 | |
import org.apache.giraph.worker.BspServiceWorker; |
23 | |
import org.apache.giraph.worker.LocalData; |
24 | |
import org.apache.hadoop.io.ByteWritable; |
25 | |
import org.apache.hadoop.io.DoubleWritable; |
26 | |
import org.apache.hadoop.io.FloatWritable; |
27 | |
import org.apache.hadoop.io.IntWritable; |
28 | |
import org.apache.hadoop.io.LongWritable; |
29 | |
import org.apache.hadoop.io.NullWritable; |
30 | |
import org.apache.hadoop.io.Writable; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | 0 | @SuppressWarnings("unchecked") |
39 | 0 | public class LongByteTranslateEdge<E extends Writable> |
40 | |
extends DefaultImmutableClassesGiraphConfigurable |
41 | |
implements TranslateEdge<LongWritable, E> { |
42 | |
|
43 | |
|
44 | |
private LocalData<LongWritable, |
45 | |
? extends Writable, E, ByteWritable> localData; |
46 | |
|
47 | |
@Override |
48 | |
public void initialize(BspServiceWorker<LongWritable, |
49 | |
? extends Writable, E> service) { |
50 | 0 | localData = (LocalData<LongWritable, ? extends Writable, E, ByteWritable>) |
51 | 0 | service.getLocalData(); |
52 | 0 | } |
53 | |
|
54 | |
@Override |
55 | |
public LongWritable translateId(LongWritable targetId) { |
56 | 0 | LongWritable translatedId = new LongWritable(); |
57 | 0 | translatedId.set(targetId.get()); |
58 | 0 | localData.getMappingStoreOps().embedTargetInfo(translatedId); |
59 | 0 | return translatedId; |
60 | |
} |
61 | |
|
62 | |
@Override |
63 | |
public E cloneValue(E edgeValue) { |
64 | |
|
65 | |
|
66 | 0 | throw new UnsupportedOperationException(); |
67 | |
} |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | 0 | public static class NoEdgeValue |
73 | |
extends LongByteTranslateEdge<NullWritable> { |
74 | |
@Override |
75 | |
public NullWritable cloneValue(NullWritable edgeValue) { |
76 | 0 | return NullWritable.get(); |
77 | |
} |
78 | |
} |
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | 0 | public static class IntEdgeValue |
84 | |
extends LongByteTranslateEdge<IntWritable> { |
85 | |
@Override |
86 | |
public IntWritable cloneValue(IntWritable edgeValue) { |
87 | 0 | return new IntWritable(edgeValue.get()); |
88 | |
} |
89 | |
} |
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | 0 | public static class LongEdgeValue |
95 | |
extends LongByteTranslateEdge<LongWritable> { |
96 | |
@Override |
97 | |
public LongWritable cloneValue(LongWritable edgeValue) { |
98 | 0 | return new LongWritable(edgeValue.get()); |
99 | |
} |
100 | |
} |
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | 0 | public static class FloatEdgeValue |
106 | |
extends LongByteTranslateEdge<FloatWritable> { |
107 | |
@Override |
108 | |
public FloatWritable cloneValue(FloatWritable edgeValue) { |
109 | 0 | return new FloatWritable(edgeValue.get()); |
110 | |
} |
111 | |
} |
112 | |
|
113 | |
|
114 | |
|
115 | |
|
116 | 0 | public static class DoubleEdgeValue |
117 | |
extends LongByteTranslateEdge<DoubleWritable> { |
118 | |
@Override |
119 | |
public DoubleWritable cloneValue(DoubleWritable edgeValue) { |
120 | 0 | return new DoubleWritable(edgeValue.get()); |
121 | |
} |
122 | |
} |
123 | |
} |