Search in sources :

Example 6 with MutableBitmap

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

the class BoundFilterBenchmark method setup.

@Setup
public void setup() throws IOException {
    step = (END_INT - START_INT) / cardinality;
    final BitmapFactory bitmapFactory = new RoaringBitmapFactory();
    final BitmapSerdeFactory serdeFactory = new RoaringBitmapSerdeFactory(null);
    final List<Integer> ints = generateInts();
    final GenericIndexed<String> dictionary = GenericIndexed.fromIterable(FluentIterable.from(ints).transform(new Function<Integer, String>() {

        @Override
        public String apply(Integer i) {
            return i.toString();
        }
    }), GenericIndexed.STRING_STRATEGY);
    final BitmapIndex bitmapIndex = new BitmapIndexColumnPartSupplier(bitmapFactory, GenericIndexed.fromIterable(FluentIterable.from(ints).transform(new Function<Integer, ImmutableBitmap>() {

        @Override
        public ImmutableBitmap apply(Integer i) {
            final MutableBitmap mutableBitmap = bitmapFactory.makeEmptyMutableBitmap();
            mutableBitmap.add((i - START_INT) / step);
            return bitmapFactory.makeImmutableBitmap(mutableBitmap);
        }
    }), serdeFactory.getObjectStrategy()), dictionary).get();
    selector = new BitmapIndexSelector() {

        @Override
        public Indexed<String> getDimensionValues(String dimension) {
            return dictionary;
        }

        @Override
        public int getNumRows() {
            throw new UnsupportedOperationException();
        }

        @Override
        public BitmapFactory getBitmapFactory() {
            return bitmapFactory;
        }

        @Override
        public ImmutableBitmap getBitmapIndex(String dimension, String value) {
            return bitmapIndex.getBitmap(bitmapIndex.getIndex(value));
        }

        @Override
        public BitmapIndex getBitmapIndex(String dimension) {
            return bitmapIndex;
        }

        @Override
        public ImmutableRTree getSpatialIndex(String dimension) {
            throw new UnsupportedOperationException();
        }
    };
}
Also used : ImmutableBitmap(io.druid.collections.bitmap.ImmutableBitmap) MutableBitmap(io.druid.collections.bitmap.MutableBitmap) BitmapIndex(io.druid.segment.column.BitmapIndex) Function(com.google.common.base.Function) ImmutableRTree(io.druid.collections.spatial.ImmutableRTree) RoaringBitmapSerdeFactory(io.druid.segment.data.RoaringBitmapSerdeFactory) BitmapIndexColumnPartSupplier(io.druid.segment.serde.BitmapIndexColumnPartSupplier) BitmapIndexSelector(io.druid.query.filter.BitmapIndexSelector) RoaringBitmapFactory(io.druid.collections.bitmap.RoaringBitmapFactory) BitmapFactory(io.druid.collections.bitmap.BitmapFactory) RoaringBitmapFactory(io.druid.collections.bitmap.RoaringBitmapFactory) Indexed(io.druid.segment.data.Indexed) GenericIndexed(io.druid.segment.data.GenericIndexed) RoaringBitmapSerdeFactory(io.druid.segment.data.RoaringBitmapSerdeFactory) BitmapSerdeFactory(io.druid.segment.data.BitmapSerdeFactory) Setup(org.openjdk.jmh.annotations.Setup)

Example 7 with MutableBitmap

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

the class Point method makeBitmap.

private static MutableBitmap makeBitmap(int entry, BitmapFactory bitmapFactory) {
    MutableBitmap retVal = bitmapFactory.makeEmptyMutableBitmap();
    retVal.add(entry);
    return retVal;
}
Also used : MutableBitmap(io.druid.collections.bitmap.MutableBitmap)

Example 8 with MutableBitmap

use of io.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) {
        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());
        Assert.assertTrue(Sets.difference(integerSet, set).isEmpty());
    }
}
Also used : MutableBitmap(io.druid.collections.bitmap.MutableBitmap) Test(org.junit.Test)

Example 9 with MutableBitmap

use of io.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(io.druid.collections.bitmap.MutableBitmap) Test(org.junit.Test)

Example 10 with MutableBitmap

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

the class TestIntegerSet method testRetainAll.

@Test
public void testRetainAll() 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.remove(1);
        set.add(9999);
        boolean threwError = false;
        try {
            integerSet.retainAll(set);
        } catch (UnsupportedOperationException ex) {
            threwError = true;
        }
        Assert.assertTrue(threwError);
    }
}
Also used : MutableBitmap(io.druid.collections.bitmap.MutableBitmap) Test(org.junit.Test)

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