1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * distributed under the License is distributed on an "AS IS" BASIS,14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15 * See the License for the specific language governing permissions and16 * limitations under the License.17 */18package org.apache.giraph.types;
1920import org.apache.giraph.types.ops.LongTypeOps;
21import org.apache.giraph.types.ops.collections.BasicSet;
22import org.apache.giraph.types.ops.collections.array.WArrayList;
23import org.apache.hadoop.io.LongWritable;
24import org.junit.Assert;
25import org.junit.Ignore;
26import org.junit.Test;
2728/**29 * Test basic collections30 */31publicclassTestCollections {
32 @Test
33publicvoid testBasicSet() {
34 BasicSet<LongWritable> longSet = LongTypeOps.INSTANCE.createOpenHashSet();
35long count = 13;
36for (long i = 1, j = 0; j < count; i *= 10, j++) {
37 longSet.add(new LongWritable(i));
38 }
39 Assert.assertEquals(count, longSet.size());
4041 longSet.clear();
42 Assert.assertEquals(0, longSet.size());
43 }
4445 @Test
46 @Ignore("this test requires 32G to run")
47publicvoid testLargeBasicSet() {
48long 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 }
5455 @Test
56 @Ignore("this test requires 1G to run")
57publicvoid testLargeBasicList() {
58int 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 }