Search in sources :

Example 21 with MutableBitmap

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);
    }
}
Also used : MutableBitmap(io.druid.collections.bitmap.MutableBitmap) Test(org.junit.Test)

Example 22 with MutableBitmap

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());
    }
}
Also used : MutableBitmap(io.druid.collections.bitmap.MutableBitmap) Test(org.junit.Test)

Example 23 with MutableBitmap

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);
}
Also used : ImmutableBitmap(io.druid.collections.bitmap.ImmutableBitmap) MutableBitmap(io.druid.collections.bitmap.MutableBitmap) Offset(io.druid.segment.data.Offset) Test(org.junit.Test)

Example 24 with MutableBitmap

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());
}
Also used : MutableBitmap(io.druid.collections.bitmap.MutableBitmap) Test(org.junit.Test) BenchmarkOptions(com.carrotsearch.junitbenchmarks.BenchmarkOptions)

Example 25 with MutableBitmap

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());
}
Also used : MutableBitmap(io.druid.collections.bitmap.MutableBitmap) Test(org.junit.Test) BenchmarkOptions(com.carrotsearch.junitbenchmarks.BenchmarkOptions)

Aggregations

MutableBitmap (io.druid.collections.bitmap.MutableBitmap)28 Test (org.junit.Test)15 ImmutableBitmap (io.druid.collections.bitmap.ImmutableBitmap)7 BitmapFactory (io.druid.collections.bitmap.BitmapFactory)5 BitmapIndexSelector (io.druid.query.filter.BitmapIndexSelector)4 BitmapIndex (io.druid.segment.column.BitmapIndex)4 BenchmarkOptions (com.carrotsearch.junitbenchmarks.BenchmarkOptions)3 Function (com.google.common.base.Function)3 RoaringBitmapFactory (io.druid.collections.bitmap.RoaringBitmapFactory)3 ImmutableRTree (io.druid.collections.spatial.ImmutableRTree)3 BitmapSerdeFactory (io.druid.segment.data.BitmapSerdeFactory)3 GenericIndexed (io.druid.segment.data.GenericIndexed)3 Indexed (io.druid.segment.data.Indexed)3 RoaringBitmapSerdeFactory (io.druid.segment.data.RoaringBitmapSerdeFactory)3 BitmapIndexColumnPartSupplier (io.druid.segment.serde.BitmapIndexColumnPartSupplier)3 Setup (org.openjdk.jmh.annotations.Setup)3 ConciseBitmapFactory (io.druid.collections.bitmap.ConciseBitmapFactory)1 WrappedImmutableRoaringBitmap (io.druid.collections.bitmap.WrappedImmutableRoaringBitmap)1 WrappedRoaringBitmap (io.druid.collections.bitmap.WrappedRoaringBitmap)1 EmptyIntIterator (io.druid.extendedset.intset.EmptyIntIterator)1