Package org.apache.druid.query
Interface BitmapResultFactory<T>
- Type Parameters:
T- the bitmap result (wrapper) type
- All Known Implementing Classes:
DefaultBitmapResultFactory
public interface BitmapResultFactory<T>
BitmapResultFactory is an abstraction that allows to record something along with preFilter bitmap construction, and
emit this information as dimension(s) of query metrics. BitmapResultFactory is similar to
BitmapFactory: it
has the same methods with the exception that it accepts generic type T (bitmap wrapper type) instead of ImmutableBitmap.
DefaultBitmapResultFactory is a no-op implementation, where "wrapper" type is ImmutableBitmap itself.
BitmapResultFactory delegates actual operations on bitmaps to a BitmapFactory, which it accepts in
constructor, called from QueryMetrics.makeBitmapResultFactory(BitmapFactory).
Emitting of query metric dimension(s) should be done from toImmutableBitmap(Object), the "unwrapping"
method, called only once to obtain the final preFilter bitmap.
Implementors expectations
-------------------------
BitmapResultFactory is a part of the QueryMetrics subsystem, so this interface could be changed often, in
every Druid release (including "patch" releases). Users who create their custom implementations of
BitmapResultFactory should be ready to fix the code of their code to accommodate interface changes (e. g. implement
new methods) when they update Druid. See QueryMetrics Javadoc for more info.-
Method Summary
Modifier and TypeMethodDescriptioncomplement(T bitmapResult, int numRows) Delegates toBitmapFactory.complement(ImmutableBitmap, int)on the wrapped bitmap, and returns a bitmap result wrapping the resulting complement ImmutableBitmap.intersection(Iterable<T> bitmapResults) Delegates toBitmapFactory.intersection(Iterable)on the wrapped bitmaps, and returns a bitmap result wrapping the resulting intersection ImmutableBitmap.booleanChecks that the wrapped bitmap is empty, seeImmutableBitmap.isEmpty().toImmutableBitmap(T bitmapResult) Unwraps bitmapResult back to ImmutableBitmap.Delegates toBitmapFactory.union(Iterable)on the wrapped bitmaps, and returns a bitmap result wrapping the resulting union ImmutableBitmap.unionDimensionValueBitmaps(Iterable<ImmutableBitmap> dimensionValueBitmaps) Equivalent of intersection(Iterables.transform(dimensionValueBitmaps, factory::wrapDimensionValue)), but doesn't create a lot of bitmap result objects.wrapAllFalse(ImmutableBitmap allFalseBitmap) Wraps a bitmap which is a result ofBitmapFactory.makeEmptyImmutableBitmap()call.wrapAllTrue(ImmutableBitmap allTrueBitmap) Wraps a bitmap which is a result ofBitmapFactory.complement(ImmutableBitmap, int)called withBitmapFactory.makeEmptyImmutableBitmap()as argument.wrapDimensionValue(ImmutableBitmap bitmap) Wraps a bitmap which designates rows in a segment with some specific dimension value.
-
Method Details
-
wrapDimensionValue
Wraps a bitmap which designates rows in a segment with some specific dimension value. -
wrapAllFalse
Wraps a bitmap which is a result ofBitmapFactory.makeEmptyImmutableBitmap()call. -
wrapAllTrue
Wraps a bitmap which is a result ofBitmapFactory.complement(ImmutableBitmap, int)called withBitmapFactory.makeEmptyImmutableBitmap()as argument. -
isEmpty
Checks that the wrapped bitmap is empty, seeImmutableBitmap.isEmpty(). -
intersection
Delegates toBitmapFactory.intersection(Iterable)on the wrapped bitmaps, and returns a bitmap result wrapping the resulting intersection ImmutableBitmap. -
union
Delegates toBitmapFactory.union(Iterable)on the wrapped bitmaps, and returns a bitmap result wrapping the resulting union ImmutableBitmap. -
unionDimensionValueBitmaps
Equivalent of intersection(Iterables.transform(dimensionValueBitmaps, factory::wrapDimensionValue)), but doesn't create a lot of bitmap result objects. -
complement
Delegates toBitmapFactory.complement(ImmutableBitmap, int)on the wrapped bitmap, and returns a bitmap result wrapping the resulting complement ImmutableBitmap. -
toImmutableBitmap
Unwraps bitmapResult back to ImmutableBitmap. BitmapResultFactory should emit query metric dimension(s) in the implementation of this method.
-