use of org.apache.druid.extendedset.intset.ConciseSet in project druid by druid-io.
the class BitmapOperationAgainstConsecutiveRunsTest method prepareRandomRanges.
@BeforeClass
public static void prepareRandomRanges() throws Exception {
reset();
final BitSet expectedUnion = new BitSet();
for (int i = 0; i < NUM_BITMAPS; ++i) {
ConciseSet c = new ConciseSet();
MutableRoaringBitmap r = new MutableRoaringBitmap();
{
int k = 0;
boolean fill = true;
while (k < BITMAP_LENGTH) {
int runLength = (int) (BITMAP_LENGTH * DENSITY) + rand.nextInt((int) (BITMAP_LENGTH * DENSITY));
for (int j = k; fill && j < BITMAP_LENGTH && j < k + runLength; ++j) {
c.add(j);
r.add(j);
expectedUnion.set(j);
}
k += runLength;
fill = !fill;
}
}
minIntersection = MIN_INTERSECT;
for (int k = BITMAP_LENGTH / 2; k < BITMAP_LENGTH / 2 + minIntersection; ++k) {
c.add(k);
r.add(k);
expectedUnion.set(k);
}
CONCISE[i] = ImmutableConciseSet.newImmutableFromMutable(c);
OFF_HEAP_CONCISE[i] = makeOffheapConcise(CONCISE[i]);
ROARING[i] = r;
IMMUTABLE_ROARING[i] = makeImmutableRoaring(r);
OFF_HEAP_ROARING[i] = makeOffheapRoaring(r);
GENERIC_CONCISE[i] = new WrappedImmutableConciseBitmap(OFF_HEAP_CONCISE[i]);
GENERIC_ROARING[i] = new WrappedImmutableRoaringBitmap(OFF_HEAP_ROARING[i]);
}
unionCount = expectedUnion.cardinality();
printSizeStats(DENSITY, "Random Alternating Bitmap");
}
use of org.apache.druid.extendedset.intset.ConciseSet in project druid by druid-io.
the class BitmapOperationAgainstUniformDistributionTest method prepareMostlyUniform.
@BeforeClass
public static void prepareMostlyUniform() throws Exception {
reset();
final BitSet expectedUnion = new BitSet();
final int[] knownTrue = new int[MIN_INTERSECT];
for (int i = 0; i < knownTrue.length; ++i) {
knownTrue[i] = rand.nextInt(BITMAP_LENGTH);
}
for (int i = 0; i < NUM_BITMAPS; ++i) {
ConciseSet c = new ConciseSet();
MutableRoaringBitmap r = new MutableRoaringBitmap();
for (int k = 0; k < BITMAP_LENGTH; ++k) {
if (rand.nextDouble() < DENSITY) {
c.add(k);
r.add(k);
expectedUnion.set(k);
}
}
for (int k : knownTrue) {
c.add(k);
r.add(k);
expectedUnion.set(k);
}
CONCISE[i] = ImmutableConciseSet.newImmutableFromMutable(c);
OFF_HEAP_CONCISE[i] = makeOffheapConcise(CONCISE[i]);
ROARING[i] = r;
IMMUTABLE_ROARING[i] = makeImmutableRoaring(r);
OFF_HEAP_ROARING[i] = makeOffheapRoaring(r);
GENERIC_CONCISE[i] = new WrappedImmutableConciseBitmap(OFF_HEAP_CONCISE[i]);
GENERIC_ROARING[i] = new WrappedImmutableRoaringBitmap(OFF_HEAP_ROARING[i]);
}
unionCount = expectedUnion.cardinality();
minIntersection = knownTrue.length;
printSizeStats(DENSITY, "Uniform Bitmap");
}
use of org.apache.druid.extendedset.intset.ConciseSet in project druid by druid-io.
the class NullHandlingBitmapGetVsIteratorBenchmark method setup.
@Setup
public void setup() {
pretendFilterOffsets = new BitSet(numRows);
switch(bitmapType) {
case "concise":
ConciseSet conciseSet = new ConciseSet();
for (int i = 0; i < numRows; i++) {
double rando = ThreadLocalRandom.current().nextDouble(0.0, 1.0);
if (filterMatch == 1.0 || rando < filterMatch) {
pretendFilterOffsets.set(i);
}
if (rando < nullDensity) {
conciseSet.add(i);
}
}
bitmap = new WrappedImmutableConciseBitmap(ImmutableConciseSet.newImmutableFromMutable(conciseSet));
break;
case "roaring":
MutableRoaringBitmap roaringBitmap = new MutableRoaringBitmap();
for (int i = 0; i < numRows; i++) {
double rando = ThreadLocalRandom.current().nextDouble(0.0, 1.0);
if (filterMatch == 1.0 || rando < filterMatch) {
pretendFilterOffsets.set(i);
}
if (rando < nullDensity) {
roaringBitmap.add(i);
}
}
bitmap = new WrappedImmutableRoaringBitmap(roaringBitmap.toImmutableRoaringBitmap());
break;
}
}
use of org.apache.druid.extendedset.intset.ConciseSet in project druid by druid-io.
the class ConciseBitmapFactoryTest method testGetOutOfBounds.
@Test
public void testGetOutOfBounds() {
final ConciseSet conciseSet = new ConciseSet();
final Set<Integer> ints = ImmutableSet.of(0, 4, 9);
for (int i : ints) {
conciseSet.add(i);
}
final ImmutableBitmap immutableBitmap = new WrappedImmutableConciseBitmap(ImmutableConciseSet.newImmutableFromMutable(conciseSet));
final MutableBitmap mutableBitmap = new WrappedConciseBitmap(conciseSet);
for (int i = 0; i < 10; ++i) {
Assert.assertEquals(Integer.toString(i), ints.contains(i), mutableBitmap.get(i));
Assert.assertEquals(Integer.toString(i), ints.contains(i), immutableBitmap.get(i));
}
}
use of org.apache.druid.extendedset.intset.ConciseSet in project druid by druid-io.
the class WrappedConciseBitmap method or.
@Override
public void or(MutableBitmap mutableBitmap) {
WrappedConciseBitmap other = (WrappedConciseBitmap) mutableBitmap;
ConciseSet unwrappedOtherBitmap = other.bitmap;
bitmap.addAll(unwrappedOtherBitmap);
}
Aggregations