use of io.druid.collections.bitmap.MutableBitmap in project druid by druid-io.
the class TestIntegerSet method testRemoveEverything.
@Test
public void testRemoveEverything() 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.removeAll(set);
boolean isEmpty = integerSet.isEmpty();
Assert.assertTrue(isEmpty);
}
}
use of io.druid.collections.bitmap.MutableBitmap in project druid by druid-io.
the class TestIntegerSet method testIsEmpty.
@Test
public void testIsEmpty() throws IllegalAccessException, InstantiationException {
for (Class<? extends MutableBitmap> clazz : clazzes) {
MutableBitmap wrappedBitmap = clazz.newInstance();
IntSetTestUtility.addAllToMutable(wrappedBitmap, IntSetTestUtility.getSetBits());
IntegerSet integerSet = IntegerSet.wrap(wrappedBitmap);
Assert.assertFalse(integerSet.isEmpty());
integerSet.clear();
Assert.assertTrue(integerSet.isEmpty());
integerSet.add(1);
Assert.assertFalse(integerSet.isEmpty());
}
}
use of io.druid.collections.bitmap.MutableBitmap in project druid by druid-io.
the class BitmapOffsetTest method testSanity.
@Test
public void testSanity() throws Exception {
MutableBitmap mutable = factory.makeEmptyMutableBitmap();
for (int val : TEST_VALS) {
mutable.add(val);
}
ImmutableBitmap bitmap = factory.makeImmutableBitmap(mutable);
final BitmapOffset offset = BitmapOffset.of(bitmap, descending, bitmap.size());
final int[] expected = descending ? TEST_VALS_FLIP : TEST_VALS;
int count = 0;
while (offset.withinBounds()) {
Assert.assertEquals(expected[count], offset.getOffset());
int cloneCount = count;
Offset clonedOffset = offset.clone();
while (clonedOffset.withinBounds()) {
Assert.assertEquals(expected[cloneCount], clonedOffset.getOffset());
++cloneCount;
clonedOffset.increment();
}
++count;
offset.increment();
}
Assert.assertEquals(count, expected.length);
}
use of io.druid.collections.bitmap.MutableBitmap in project druid by druid-io.
the class BitmapCreationBenchmark method testRandomAddition.
@BenchmarkOptions(warmupRounds = 10, benchmarkRounds = 10)
@Test
public void testRandomAddition() {
MutableBitmap mutableBitmap = factory.makeEmptyMutableBitmap();
for (int i : randIndex) {
mutableBitmap.add(i);
}
Assert.assertEquals(numBits, mutableBitmap.size());
}
use of io.druid.collections.bitmap.MutableBitmap in project druid by druid-io.
the class BitmapCreationBenchmark method testLinearAdditionDescending.
@BenchmarkOptions(warmupRounds = 10, benchmarkRounds = 1000)
@Test
public void testLinearAdditionDescending() {
MutableBitmap mutableBitmap = factory.makeEmptyMutableBitmap();
for (int i = numBits - 1; i >= 0; --i) {
mutableBitmap.add(i);
}
Assert.assertEquals(numBits, mutableBitmap.size());
}
Aggregations