1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
package org.apache.giraph.types.ops; |
19 | |
|
20 | |
import org.apache.giraph.types.ops.collections.Basic2ObjectMap.BasicInt2ObjectOpenHashMap; |
21 | |
import org.apache.giraph.types.ops.collections.BasicSet.BasicIntOpenHashSet; |
22 | |
import org.apache.giraph.types.ops.collections.array.WIntArrayList; |
23 | |
import org.apache.giraph.types.ops.collections.WritableWriter; |
24 | |
import org.apache.hadoop.io.IntWritable; |
25 | |
|
26 | |
import java.io.DataInput; |
27 | |
import java.io.IOException; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | 0 | public enum IntTypeOps implements |
34 | |
PrimitiveIdTypeOps<IntWritable>, NumericTypeOps<IntWritable> { |
35 | |
|
36 | 0 | INSTANCE; |
37 | |
|
38 | |
@Override |
39 | |
public Class<IntWritable> getTypeClass() { |
40 | 0 | return IntWritable.class; |
41 | |
} |
42 | |
|
43 | |
@Override |
44 | |
public IntWritable create() { |
45 | 0 | return new IntWritable(); |
46 | |
} |
47 | |
|
48 | |
@Override |
49 | |
public IntWritable createCopy(IntWritable from) { |
50 | 0 | return new IntWritable(from.get()); |
51 | |
} |
52 | |
|
53 | |
@Override |
54 | |
public void set(IntWritable to, IntWritable from) { |
55 | 0 | to.set(from.get()); |
56 | 0 | } |
57 | |
|
58 | |
@Override |
59 | |
public WIntArrayList createArrayList() { |
60 | 0 | return new WIntArrayList(); |
61 | |
} |
62 | |
|
63 | |
@Override |
64 | |
public WIntArrayList createArrayList(int capacity) { |
65 | 0 | return new WIntArrayList(capacity); |
66 | |
} |
67 | |
|
68 | |
@Override |
69 | |
public WIntArrayList readNewArrayList(DataInput in) throws IOException { |
70 | 0 | return WIntArrayList.readNew(in); |
71 | |
} |
72 | |
|
73 | |
@Override |
74 | |
public BasicIntOpenHashSet createOpenHashSet() { |
75 | 0 | return new BasicIntOpenHashSet(); |
76 | |
} |
77 | |
|
78 | |
@Override |
79 | |
public BasicIntOpenHashSet createOpenHashSet(long capacity) { |
80 | 0 | return new BasicIntOpenHashSet(capacity); |
81 | |
} |
82 | |
|
83 | |
@Override |
84 | |
public <V> BasicInt2ObjectOpenHashMap<V> create2ObjectOpenHashMap( |
85 | |
WritableWriter<V> valueWriter) { |
86 | 0 | return new BasicInt2ObjectOpenHashMap<>(valueWriter); |
87 | |
} |
88 | |
|
89 | |
@Override |
90 | |
public <V> BasicInt2ObjectOpenHashMap<V> create2ObjectOpenHashMap( |
91 | |
int capacity, WritableWriter<V> valueWriter) { |
92 | 0 | return new BasicInt2ObjectOpenHashMap<>(capacity, valueWriter); |
93 | |
} |
94 | |
|
95 | |
@Override |
96 | |
public IntWritable createZero() { |
97 | 0 | return new IntWritable(0); |
98 | |
} |
99 | |
|
100 | |
@Override |
101 | |
public IntWritable createOne() { |
102 | 0 | return new IntWritable(1); |
103 | |
} |
104 | |
|
105 | |
@Override |
106 | |
public IntWritable createMinNegativeValue() { |
107 | 0 | return new IntWritable(Integer.MIN_VALUE); |
108 | |
} |
109 | |
|
110 | |
@Override |
111 | |
public IntWritable createMaxPositiveValue() { |
112 | 0 | return new IntWritable(Integer.MAX_VALUE); |
113 | |
} |
114 | |
|
115 | |
@Override |
116 | |
public void plusInto(IntWritable value, IntWritable increment) { |
117 | 0 | value.set(value.get() + increment.get()); |
118 | 0 | } |
119 | |
|
120 | |
@Override |
121 | |
public void multiplyInto(IntWritable value, IntWritable multiplier) { |
122 | 0 | value.set(value.get() * multiplier.get()); |
123 | 0 | } |
124 | |
|
125 | |
@Override |
126 | |
public void negate(IntWritable value) { |
127 | 0 | value.set(-value.get()); |
128 | 0 | } |
129 | |
|
130 | |
@Override |
131 | |
public int compare(IntWritable value1, IntWritable value2) { |
132 | 0 | return Integer.compare(value1.get(), value2.get()); |
133 | |
} |
134 | |
} |