Search in sources :

Example 1 with MutableBitmap

use of org.apache.druid.collections.bitmap.MutableBitmap in project druid by druid-io.

the class TestIntegerSet method testSize.

@Test
public void testSize() 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.assertEquals(set.size(), integerSet.size());
    }
}
Also used : MutableBitmap(org.apache.druid.collections.bitmap.MutableBitmap) Test(org.junit.Test)

Example 2 with MutableBitmap

use of org.apache.druid.collections.bitmap.MutableBitmap in project druid by druid-io.

the class TestIntegerSet method testToArray.

@Test
public void testToArray() 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 = Sets.newHashSet((Integer[]) integerSet.toArray());
        Assert.assertTrue(Sets.difference(integerSet, set).isEmpty());
    }
}
Also used : MutableBitmap(org.apache.druid.collections.bitmap.MutableBitmap) Test(org.junit.Test)

Example 3 with MutableBitmap

use of org.apache.druid.collections.bitmap.MutableBitmap in project druid by druid-io.

the class TestIntegerSet method testSimpleAdd.

@Test
public void testSimpleAdd() 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();
        set.add(999);
        integerSet.add(999);
        Assert.assertTrue(Sets.difference(integerSet, set).isEmpty());
        integerSet.add(58577);
        Assert.assertFalse(Sets.difference(integerSet, set).isEmpty());
    }
}
Also used : MutableBitmap(org.apache.druid.collections.bitmap.MutableBitmap) Test(org.junit.Test)

Example 4 with MutableBitmap

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

Example 5 with MutableBitmap

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

Aggregations

MutableBitmap (org.apache.druid.collections.bitmap.MutableBitmap)33 Test (org.junit.Test)15 BitmapFactory (org.apache.druid.collections.bitmap.BitmapFactory)8 ImmutableBitmap (org.apache.druid.collections.bitmap.ImmutableBitmap)7 RoaringBitmapFactory (org.apache.druid.collections.bitmap.RoaringBitmapFactory)6 Setup (org.openjdk.jmh.annotations.Setup)6 ArrayList (java.util.ArrayList)4 ConciseBitmapFactory (org.apache.druid.collections.bitmap.ConciseBitmapFactory)4 BitmapIndex (org.apache.druid.segment.column.BitmapIndex)4 BitmapSerdeFactory (org.apache.druid.segment.data.BitmapSerdeFactory)4 Benchmark (org.openjdk.jmh.annotations.Benchmark)4 BenchmarkOptions (com.carrotsearch.junitbenchmarks.BenchmarkOptions)3 Function (com.google.common.base.Function)3 List (java.util.List)3 Random (java.util.Random)3 TimeUnit (java.util.concurrent.TimeUnit)3 NullHandling (org.apache.druid.common.config.NullHandling)3 IAE (org.apache.druid.java.util.common.IAE)3 RoaringBitmapSerdeFactory (org.apache.druid.segment.data.RoaringBitmapSerdeFactory)3 StringBitmapIndexColumnPartSupplier (org.apache.druid.segment.serde.StringBitmapIndexColumnPartSupplier)3