Search in sources :

Example 21 with TupleDomainFilter

use of com.facebook.presto.common.predicate.TupleDomainFilter in project presto by prestodb.

the class MapDirectSelectiveStreamReader method getTopLevelFilter.

private static Optional<TupleDomainFilter> getTopLevelFilter(Map<Subfield, TupleDomainFilter> filters) {
    Map<Subfield, TupleDomainFilter> topLevelFilters = Maps.filterEntries(filters, entry -> entry.getKey().getPath().isEmpty());
    if (topLevelFilters.isEmpty()) {
        return Optional.empty();
    }
    checkArgument(topLevelFilters.size() == 1, "MAP column may have at most one top-level range filter");
    TupleDomainFilter filter = Iterables.getOnlyElement(topLevelFilters.values());
    checkArgument(filter == IS_NULL || filter == IS_NOT_NULL, "Top-level range filter on MAP column must be IS NULL or IS NOT NULL");
    return Optional.of(filter);
}
Also used : Subfield(com.facebook.presto.common.Subfield) TupleDomainFilter(com.facebook.presto.common.predicate.TupleDomainFilter)

Example 22 with TupleDomainFilter

use of com.facebook.presto.common.predicate.TupleDomainFilter in project presto by prestodb.

the class MapFlatSelectiveStreamReader method getTopLevelFilter.

private static Optional<TupleDomainFilter> getTopLevelFilter(Map<Subfield, TupleDomainFilter> filters) {
    Map<Subfield, TupleDomainFilter> topLevelFilters = Maps.filterEntries(filters, entry -> entry.getKey().getPath().isEmpty());
    if (topLevelFilters.isEmpty()) {
        return Optional.empty();
    }
    checkArgument(topLevelFilters.size() == 1, "MAP column may have at most one top-level range filter");
    TupleDomainFilter filter = Iterables.getOnlyElement(topLevelFilters.values());
    checkArgument(filter == IS_NULL || filter == IS_NOT_NULL, "Top-level range filter on MAP column must be IS NULL or IS NOT NULL");
    return Optional.of(filter);
}
Also used : Subfield(com.facebook.presto.common.Subfield) TupleDomainFilter(com.facebook.presto.common.predicate.TupleDomainFilter)

Example 23 with TupleDomainFilter

use of com.facebook.presto.common.predicate.TupleDomainFilter in project presto by prestodb.

the class ListFilter method setupNullsFilter.

private void setupNullsFilter() {
    int count = topLevelOffsets[topLevelOffsetCount - 1];
    nullsAllowed = ensureCapacity(nullsAllowed, count);
    nonNullsAllowed = ensureCapacity(nonNullsAllowed, count);
    for (int i = 0; i < count; i++) {
        long filter = elementFilters[i] & nullFilters;
        if (filter > 0) {
            TupleDomainFilter tupleDomainFilter = tupleDomainFilters[numberOfTrailingZeros(filter)];
            nullsAllowed[i] = tupleDomainFilter == IS_NULL;
            nonNullsAllowed[i] = tupleDomainFilter == IS_NOT_NULL;
        } else {
            nullsAllowed[i] = true;
            nonNullsAllowed[i] = true;
        }
    }
    nullsFilter.setup(nullsAllowed, nonNullsAllowed, topLevelOffsets);
}
Also used : TupleDomainFilter(com.facebook.presto.common.predicate.TupleDomainFilter)

Aggregations

TupleDomainFilter (com.facebook.presto.common.predicate.TupleDomainFilter)23 Subfield (com.facebook.presto.common.Subfield)20 ImmutableMap (com.google.common.collect.ImmutableMap)12 Map (java.util.Map)12 ImmutableList (com.google.common.collect.ImmutableList)11 Test (org.testng.annotations.Test)11 Type (com.facebook.presto.common.type.Type)9 ImmutableMap.toImmutableMap (com.google.common.collect.ImmutableMap.toImmutableMap)9 Optional (java.util.Optional)9 List (java.util.List)8 Block (com.facebook.presto.common.block.Block)7 HashMap (java.util.HashMap)7 Objects (java.util.Objects)7 Page (com.facebook.presto.common.Page)6 BigintRange (com.facebook.presto.common.predicate.TupleDomainFilter.BigintRange)6 CharType (com.facebook.presto.common.type.CharType)6 DecimalType (com.facebook.presto.common.type.DecimalType)6 ArrayList (java.util.ArrayList)6 Arrays (java.util.Arrays)6 PositionalFilter (com.facebook.presto.common.predicate.TupleDomainFilter.PositionalFilter)5