use of org.apache.druid.collections.bitmap.WrappedImmutableRoaringBitmap in project druid by druid-io.
the class BitmapOffset method getReverseBitmapOffsetIterator.
static IntIterator getReverseBitmapOffsetIterator(ImmutableBitmap bitmapIndex) {
ImmutableBitmap roaringBitmap = bitmapIndex;
if (!(bitmapIndex instanceof WrappedImmutableRoaringBitmap)) {
final MutableBitmap bitmap = ROARING_BITMAP_FACTORY.makeEmptyMutableBitmap();
final IntIterator iterator = bitmapIndex.iterator();
while (iterator.hasNext()) {
bitmap.add(iterator.next());
}
roaringBitmap = ROARING_BITMAP_FACTORY.makeImmutableBitmap(bitmap);
}
return ((WrappedImmutableRoaringBitmap) roaringBitmap).getBitmap().getReverseIntIterator();
}
use of org.apache.druid.collections.bitmap.WrappedImmutableRoaringBitmap in project druid by druid-io.
the class BitmapVectorOffsetTest method testNotContiguousGetStartOffsetIsExplode.
@Test
public void testNotContiguousGetStartOffsetIsExplode() {
MutableRoaringBitmap wrapped = new MutableRoaringBitmap();
for (int i = 0; i < ROWS; i++) {
if (i % 2 != 0) {
wrapped.add(i);
}
}
ImmutableBitmap bitmap = new WrappedImmutableRoaringBitmap(wrapped.toImmutableRoaringBitmap());
BitmapVectorOffset offset = new BitmapVectorOffset(VECTOR_SIZE, bitmap, 0, ROWS);
expectedException.expect(UnsupportedOperationException.class);
expectedException.expectMessage("not contiguous");
offset.getStartOffset();
}
use of org.apache.druid.collections.bitmap.WrappedImmutableRoaringBitmap in project druid by druid-io.
the class BitmapVectorOffsetTest method testContiguousGetOffsetsIsExplode.
@Test
public void testContiguousGetOffsetsIsExplode() {
MutableRoaringBitmap wrapped = new MutableRoaringBitmap();
for (int i = 0; i < ROWS; i++) {
wrapped.add(i);
}
ImmutableBitmap bitmap = new WrappedImmutableRoaringBitmap(wrapped.toImmutableRoaringBitmap());
BitmapVectorOffset offset = new BitmapVectorOffset(VECTOR_SIZE, bitmap, 0, ROWS);
expectedException.expect(UnsupportedOperationException.class);
expectedException.expectMessage("is contiguous");
offset.getOffsets();
}
use of org.apache.druid.collections.bitmap.WrappedImmutableRoaringBitmap in project druid by druid-io.
the class BitmapVectorOffsetTest method testNeverContiguous.
@Test
public void testNeverContiguous() {
MutableRoaringBitmap wrapped = new MutableRoaringBitmap();
for (int i = 0; i < ROWS; i++) {
if (i % 2 != 0) {
wrapped.add(i);
}
}
ImmutableBitmap bitmap = new WrappedImmutableRoaringBitmap(wrapped.toImmutableRoaringBitmap());
for (int startOffset = 0; startOffset < ROWS; startOffset++) {
BitmapVectorOffset offset = new BitmapVectorOffset(VECTOR_SIZE, bitmap, startOffset, ROWS);
while (!offset.isDone()) {
Assert.assertFalse(offset.isContiguous());
offset.advance();
}
}
}
use of org.apache.druid.collections.bitmap.WrappedImmutableRoaringBitmap in project druid by druid-io.
the class BitmapVectorOffsetTest method testContiguous.
@Test
public void testContiguous() {
// every bit is set, start from every offset and ensure all batches are contiguous
MutableRoaringBitmap wrapped = new MutableRoaringBitmap();
for (int i = 0; i < ROWS; i++) {
wrapped.add(i);
}
ImmutableBitmap bitmap = new WrappedImmutableRoaringBitmap(wrapped.toImmutableRoaringBitmap());
for (int startOffset = 0; startOffset < ROWS; startOffset++) {
BitmapVectorOffset offset = new BitmapVectorOffset(VECTOR_SIZE, bitmap, startOffset, ROWS);
while (!offset.isDone()) {
if (offset.getCurrentVectorSize() > 1) {
Assert.assertTrue(offset.isContiguous());
}
offset.advance();
}
}
}
Aggregations