use of org.apache.druid.collections.bitmap.WrappedImmutableConciseBitmap in project druid by druid-io.
the class BitmapBenchmarkUtils method toOffheap.
public static ImmutableBitmap toOffheap(ImmutableBitmap bitmap) throws IOException {
if (bitmap instanceof WrappedImmutableConciseBitmap) {
final WrappedImmutableConciseBitmap conciseBitmap = (WrappedImmutableConciseBitmap) bitmap;
final byte[] bytes = conciseBitmap.getBitmap().toBytes();
final ByteBuffer buf = ByteBuffer.allocateDirect(bytes.length).put(bytes);
buf.rewind();
return new WrappedImmutableConciseBitmap(new ImmutableConciseSet(buf.asIntBuffer()));
} else if (bitmap instanceof WrappedImmutableRoaringBitmap) {
final WrappedImmutableRoaringBitmap roaringBitmap = (WrappedImmutableRoaringBitmap) bitmap;
final ByteArrayOutputStream out = new ByteArrayOutputStream();
roaringBitmap.getBitmap().serialize(new DataOutputStream(out));
final byte[] bytes = out.toByteArray();
final ByteBuffer buf = ByteBuffer.allocateDirect(bytes.length);
buf.put(bytes);
buf.rewind();
return new WrappedImmutableRoaringBitmap(new ImmutableRoaringBitmap(buf.asReadOnlyBuffer()));
} else {
throw new IAE("Unsupported bitmap type [%s]", bitmap.getClass().getSimpleName());
}
}
use of org.apache.druid.collections.bitmap.WrappedImmutableConciseBitmap 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.collections.bitmap.WrappedImmutableConciseBitmap in project druid by druid-io.
the class VectorSelectorUtilsTest method testConciseImmutableNullVector.
@Test
public void testConciseImmutableNullVector() {
final WrappedConciseBitmap bitmap = new WrappedConciseBitmap();
populate(bitmap, NULLS);
final ImmutableBitmap immutable = new WrappedImmutableConciseBitmap(ImmutableConciseSet.newImmutableFromMutable(bitmap.getBitmap()));
assertNullVector(immutable, NULLS);
final WrappedConciseBitmap bitmap2 = new WrappedConciseBitmap();
populate(bitmap2, NULLS_PATTERN);
final ImmutableBitmap immutable2 = new WrappedImmutableConciseBitmap(ImmutableConciseSet.newImmutableFromMutable(bitmap2.getBitmap()));
assertNullVector(immutable2, NULLS_PATTERN);
}
Aggregations