public static ImmutableBitmap allTrue(final BitmapIndexSelector selector) { return selector.getBitmapFactory() .complement(selector.getBitmapFactory().makeEmptyImmutableBitmap(), selector.getNumRows()); }
@Override public double estimateSelectivity(BitmapIndexSelector indexSelector) { return (double) indexSelector.getBitmapIndex(dimension, value).size() / indexSelector.getNumRows(); }
try (final CloseableIndexed<String> dimValues = indexSelector.getDimensionValues(dimension)) { if (dimValues == null || dimValues.size() == 0) { return predicate.apply(null) ? 1. : 0.; final BitmapIndex bitmapIndex = indexSelector.getBitmapIndex(dimension); return estimateSelectivity( bitmapIndex, makePredicateQualifyingIndexIterable(bitmapIndex, predicate, dimValues).iterator() ), indexSelector.getNumRows() );
@Override public boolean supportsBitmapIndex(final BitmapIndexSelector selector) { if (requiredBindings.isEmpty()) { // Constant expression. return true; } else if (requiredBindings.size() == 1) { // Single-column expression. We can use bitmap indexes if this column has an index and does not have // multiple values. The lack of multiple values is important because expression filters treat multi-value // arrays as nulls, which doesn't permit index based filtering. final String column = Iterables.getOnlyElement(requiredBindings); return selector.getBitmapIndex(column) != null && !selector.hasMultipleValues(column); } else { // Multi-column expression. return false; } }
@Override public boolean supportsBitmapIndex(BitmapIndexSelector selector) { return selector.getBitmapIndex(dimension) != null; }
try (final CloseableIndexed<String> dimValues = selector.getDimensionValues(dimension)) { if (dimValues == null || dimValues.size() == 0) { return ImmutableList.of(predicate.apply(null) ? allTrue(selector) : allFalse(selector)); final BitmapIndex bitmapIndex = selector.getBitmapIndex(dimension); return makePredicateQualifyingBitmapIterable(bitmapIndex, predicate, dimValues);
public static ImmutableBitmap allFalse(final BitmapIndexSelector selector) { return selector.getBitmapFactory().makeEmptyImmutableBitmap(); }
@Override public double estimateSelectivity(BitmapIndexSelector selector) { return Filters.estimateSelectivity(getBitmapIterable(selector).iterator(), selector.getNumRows()); }
@Override public <T> T getBitmapResult(BitmapIndexSelector selector, BitmapResultFactory<T> bitmapResultFactory) { Iterable<ImmutableBitmap> search = selector.getSpatialIndex(dimension).search(bound); return bitmapResultFactory.unionDimensionValueBitmaps(search); }
@Override public boolean supportsBitmapIndex(BitmapIndexSelector selector) { return selector.getBitmapIndex(dimension) != null; }
selector.getBitmapIndex( dimension, NullHandling.emptyToNullIfNeeded(likeMatcher.getPrefix()) } else if (isSimplePrefix()) { final BitmapIndex bitmapIndex = selector.getBitmapIndex(dimension); try (final CloseableIndexed<String> dimValues = selector.getDimensionValues(dimension)) {
/** * Get a bitmap index, indicating rows that match this filter. Do not call this method unless * {@link #supportsBitmapIndex(BitmapIndexSelector)} returns true. Behavior in the case that * {@link #supportsBitmapIndex(BitmapIndexSelector)} returns false is undefined. * * This method is OK to be called, but generally should not be overridden, override {@link #getBitmapResult} instead. * * @param selector Object used to retrieve bitmap indexes * * @return A bitmap indicating rows that match this filter. * * @see Filter#estimateSelectivity(BitmapIndexSelector) */ default ImmutableBitmap getBitmapIndex(BitmapIndexSelector selector) { return getBitmapResult(selector, new DefaultBitmapResultFactory(selector.getBitmapFactory())); }
@Override public boolean supportsBitmapIndex(final BitmapIndexSelector selector) { if (requiredBindings.isEmpty()) { // Constant expression. return true; } else if (requiredBindings.size() == 1) { // Single-column expression. We can use bitmap indexes if this column has an index and does not have // multiple values. The lack of multiple values is important because expression filters treat multi-value // arrays as nulls, which doesn't permit index based filtering. final String column = Iterables.getOnlyElement(requiredBindings); return selector.getBitmapIndex(column) != null && !selector.hasMultipleValues(column); } else { // Multi-column expression. return false; } }
@Override public <T> T getBitmapResult(BitmapIndexSelector selector, BitmapResultFactory<T> bitmapResultFactory) { return bitmapResultFactory.complement( baseFilter.getBitmapResult(selector, bitmapResultFactory), selector.getNumRows() ); }
@Override public <T> T getBitmapResult(BitmapIndexSelector selector, BitmapResultFactory<T> bitmapResultFactory) { Iterable<ImmutableBitmap> search = selector.getSpatialIndex(dimension).search(bound); return bitmapResultFactory.unionDimensionValueBitmaps(search); }
@Override public double estimateSelectivity(BitmapIndexSelector indexSelector) { if (extractionFn == null) { final BitmapIndex bitmapIndex = indexSelector.getBitmapIndex(dimension); return Filters.estimateSelectivity( bitmapIndex, IntIteratorUtils.toIntList(getBitmapIndexIterable(bitmapIndex).iterator()), indexSelector.getNumRows() ); } else { return Filters.estimateSelectivity( dimension, indexSelector, getPredicateFactory().makeStringPredicate() ); } }
@Override public boolean supportsBitmapIndex(BitmapIndexSelector selector) { return selector.getBitmapIndex(dimension) != null; }
try (final CloseableIndexed<String> dimValues = indexSelector.getDimensionValues(dimension)) { if (dimValues == null || dimValues.size() == 0) { return predicate.apply(null) ? 1. : 0.; final BitmapIndex bitmapIndex = indexSelector.getBitmapIndex(dimension); return estimateSelectivity( bitmapIndex, makePredicateQualifyingIndexIterable(bitmapIndex, predicate, dimValues).iterator() ), indexSelector.getNumRows() );
try (final CloseableIndexed<String> dimValues = selector.getDimensionValues(dimension)) { if (dimValues == null || dimValues.size() == 0) { return ImmutableList.of(predicate.apply(null) ? allTrue(selector) : allFalse(selector)); final BitmapIndex bitmapIndex = selector.getBitmapIndex(dimension); return makePredicateQualifyingBitmapIterable(bitmapIndex, predicate, dimValues);
public static ImmutableBitmap allTrue(final BitmapIndexSelector selector) { return selector.getBitmapFactory() .complement(selector.getBitmapFactory().makeEmptyImmutableBitmap(), selector.getNumRows()); }