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