use of io.druid.collections.bitmap.MutableBitmap in project druid by druid-io.
the class TestIntegerSet method testContainsAll.
@Test
public void testContainsAll() throws IllegalAccessException, InstantiationException {
for (Class<? extends MutableBitmap> clazz : clazzes) {
MutableBitmap wrappedBitmap = clazz.newInstance();
IntSetTestUtility.addAllToMutable(wrappedBitmap, IntSetTestUtility.getSetBits());
IntegerSet integerSet = IntegerSet.wrap(wrappedBitmap);
Set<Integer> set = IntSetTestUtility.getSetBits();
Assert.assertTrue(integerSet.containsAll(set));
set.add(999);
Assert.assertFalse(integerSet.containsAll(set));
}
}
use of io.druid.collections.bitmap.MutableBitmap in project druid by druid-io.
the class TestIntegerSet method testToSmallArray.
@Test
public void testToSmallArray() throws IllegalAccessException, InstantiationException {
for (Class<? extends MutableBitmap> clazz : clazzes) {
Exception e = null;
MutableBitmap wrappedBitmap = clazz.newInstance();
IntSetTestUtility.addAllToMutable(wrappedBitmap, IntSetTestUtility.getSetBits());
IntegerSet integerSet = IntegerSet.wrap(wrappedBitmap);
Set<Integer> set = Sets.newHashSet((Integer[]) integerSet.toArray(new Integer[0]));
Assert.assertTrue(Sets.difference(integerSet, set).isEmpty());
}
}
use of io.druid.collections.bitmap.MutableBitmap in project druid by druid-io.
the class TestIntegerSet method testToBigArray.
@Test
public void testToBigArray() throws IllegalAccessException, InstantiationException {
for (Class<? extends MutableBitmap> clazz : clazzes) {
Exception e = null;
MutableBitmap wrappedBitmap = clazz.newInstance();
IntSetTestUtility.addAllToMutable(wrappedBitmap, IntSetTestUtility.getSetBits());
IntegerSet integerSet = IntegerSet.wrap(wrappedBitmap);
Integer[] bigArray = new Integer[1024];
integerSet.toArray(bigArray);
Set<Integer> set = Sets.newHashSet(bigArray);
Assert.assertTrue(Sets.difference(integerSet, set).isEmpty());
}
}
use of io.druid.collections.bitmap.MutableBitmap in project druid by druid-io.
the class TestIntegerSet method testRemoveOneThing.
@Test
public void testRemoveOneThing() throws IllegalAccessException, InstantiationException {
for (Class<? extends MutableBitmap> clazz : clazzes) {
MutableBitmap wrappedBitmap = clazz.newInstance();
IntSetTestUtility.addAllToMutable(wrappedBitmap, IntSetTestUtility.getSetBits());
IntegerSet integerSet = IntegerSet.wrap(wrappedBitmap);
Set<Integer> set = IntSetTestUtility.getSetBits();
integerSet.remove(1);
set.remove(1);
Assert.assertTrue(Sets.difference(set, integerSet).isEmpty());
}
}
use of io.druid.collections.bitmap.MutableBitmap in project druid by druid-io.
the class TestIntegerSet method testIntOverflow.
@Test
public void testIntOverflow() throws IllegalAccessException, InstantiationException {
for (Class<? extends MutableBitmap> clazz : clazzes) {
Exception e = null;
try {
MutableBitmap wrappedBitmap = clazz.newInstance();
IntSetTestUtility.addAllToMutable(wrappedBitmap, IntSetTestUtility.getSetBits());
IntegerSet integerSet = IntegerSet.wrap(wrappedBitmap);
integerSet.add(Integer.MAX_VALUE + 1);
} catch (java.lang.IllegalArgumentException ex) {
e = ex;
}
Assert.assertNotNull(e);
}
}
Aggregations