1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.giraph.types;
19
20 import org.apache.giraph.types.ops.LongTypeOps;
21 import org.apache.giraph.types.ops.collections.BasicSet;
22 import org.apache.giraph.types.ops.collections.array.WArrayList;
23 import org.apache.hadoop.io.LongWritable;
24 import org.junit.Assert;
25 import org.junit.Ignore;
26 import org.junit.Test;
27
28
29
30
31 public class TestCollections {
32 @Test
33 public void testBasicSet() {
34 BasicSet<LongWritable> longSet = LongTypeOps.INSTANCE.createOpenHashSet();
35 long count = 13;
36 for (long i = 1, j = 0; j < count; i *= 10, j++) {
37 longSet.add(new LongWritable(i));
38 }
39 Assert.assertEquals(count, longSet.size());
40
41 longSet.clear();
42 Assert.assertEquals(0, longSet.size());
43 }
44
45 @Test
46 @Ignore("this test requires 32G to run")
47 public void testLargeBasicSet() {
48 long capacity = 1234567890;
49 BasicSet<LongWritable> longSet = LongTypeOps.INSTANCE.createOpenHashSet(capacity);
50 longSet.add(new LongWritable(capacity));
51 longSet.add(new LongWritable(capacity));
52 Assert.assertEquals(1, longSet.size());
53 }
54
55 @Test
56 @Ignore("this test requires 1G to run")
57 public void testLargeBasicList() {
58 int capacity = 123456789;
59 WArrayList<LongWritable> longSet = LongTypeOps.INSTANCE.createArrayList(capacity);
60 longSet.addW(new LongWritable(capacity));
61 longSet.addW(new LongWritable(capacity));
62 Assert.assertEquals(2, longSet.size());
63 }
64 }