Search in sources :

Example 11 with BitmapIndex

use of io.druid.segment.column.BitmapIndex in project druid by druid-io.

the class FiltersTest method makeNonOverlappedBitmapIndexes.

private static BitmapIndex makeNonOverlappedBitmapIndexes(final int bitmapNum, final List<ImmutableBitmap> bitmaps) {
    final BitmapIndex bitmapIndex = getBitmapIndex(bitmaps);
    final BitmapFactory factory = bitmapIndex.getBitmapFactory();
    for (int i = 0; i < bitmapNum; i++) {
        final MutableBitmap mutableBitmap = factory.makeEmptyMutableBitmap();
        for (int j = 0; j < 10; j++) {
            mutableBitmap.add(i * 10 + j);
        }
        bitmaps.add(factory.makeImmutableBitmap(mutableBitmap));
    }
    return bitmapIndex;
}
Also used : MutableBitmap(io.druid.collections.bitmap.MutableBitmap) BitmapIndex(io.druid.segment.column.BitmapIndex) BitmapFactory(io.druid.collections.bitmap.BitmapFactory) ConciseBitmapFactory(io.druid.collections.bitmap.ConciseBitmapFactory)

Example 12 with BitmapIndex

use of io.druid.segment.column.BitmapIndex in project druid by druid-io.

the class SegmentAnalyzer method analyzeStringColumn.

private ColumnAnalysis analyzeStringColumn(final ColumnCapabilities capabilities, final Column column) {
    long size = 0;
    Comparable min = null;
    Comparable max = null;
    if (!capabilities.hasBitmapIndexes()) {
        return ColumnAnalysis.error("string_no_bitmap");
    }
    final BitmapIndex bitmapIndex = column.getBitmapIndex();
    final int cardinality = bitmapIndex.getCardinality();
    if (analyzingSize()) {
        for (int i = 0; i < cardinality; ++i) {
            String value = bitmapIndex.getValue(i);
            if (value != null) {
                size += StringUtils.estimatedBinaryLengthAsUTF8(value) * bitmapIndex.getBitmap(bitmapIndex.getIndex(value)).size();
            }
        }
    }
    if (analyzingMinMax() && cardinality > 0) {
        min = Strings.nullToEmpty(bitmapIndex.getValue(0));
        max = Strings.nullToEmpty(bitmapIndex.getValue(cardinality - 1));
    }
    return new ColumnAnalysis(capabilities.getType().name(), capabilities.hasMultipleValues(), size, analyzingCardinality() ? cardinality : 0, min, max, null);
}
Also used : BitmapIndex(io.druid.segment.column.BitmapIndex) ColumnAnalysis(io.druid.query.metadata.metadata.ColumnAnalysis)

Aggregations

BitmapIndex (io.druid.segment.column.BitmapIndex)12 BitmapFactory (io.druid.collections.bitmap.BitmapFactory)5 ImmutableBitmap (io.druid.collections.bitmap.ImmutableBitmap)5 MutableBitmap (io.druid.collections.bitmap.MutableBitmap)4 RoaringBitmapFactory (io.druid.collections.bitmap.RoaringBitmapFactory)4 Column (io.druid.segment.column.Column)4 BitmapSerdeFactory (io.druid.segment.data.BitmapSerdeFactory)4 RoaringBitmapSerdeFactory (io.druid.segment.data.RoaringBitmapSerdeFactory)4 Function (com.google.common.base.Function)3 ImmutableRTree (io.druid.collections.spatial.ImmutableRTree)3 BitmapIndexSelector (io.druid.query.filter.BitmapIndexSelector)3 DictionaryEncodedColumn (io.druid.segment.column.DictionaryEncodedColumn)3 GenericColumn (io.druid.segment.column.GenericColumn)3 GenericIndexed (io.druid.segment.data.GenericIndexed)3 Indexed (io.druid.segment.data.Indexed)3 BitmapIndexColumnPartSupplier (io.druid.segment.serde.BitmapIndexColumnPartSupplier)3 Setup (org.openjdk.jmh.annotations.Setup)3 ConciseBitmapFactory (io.druid.collections.bitmap.ConciseBitmapFactory)2 ComplexColumn (io.druid.segment.column.ComplexColumn)2 IndexedFloatsGenericColumn (io.druid.segment.column.IndexedFloatsGenericColumn)2