Search in sources :

Example 6 with FilterOperator

use of com.linkedin.pinot.common.request.FilterOperator in project pinot by linkedin.

the class InPredicateAstNode method buildFilterQueryTree.

@Override
public FilterQueryTree buildFilterQueryTree() {
    if (_identifier == null) {
        throw new Pql2CompilationException("IN predicate has no identifier");
    }
    TreeSet<String> values = new TreeSet<>();
    for (AstNode astNode : getChildren()) {
        if (astNode instanceof LiteralAstNode) {
            LiteralAstNode node = (LiteralAstNode) astNode;
            values.add(node.getValueAsString());
        }
    }
    String[] valueArray = values.toArray(new String[values.size()]);
    FilterOperator filterOperator;
    if (_isNotInClause) {
        filterOperator = FilterOperator.NOT_IN;
    } else {
        filterOperator = FilterOperator.IN;
    }
    return new FilterQueryTree(_identifier, Collections.singletonList(StringUtil.join("\t\t", valueArray)), filterOperator, null);
}
Also used : FilterOperator(com.linkedin.pinot.common.request.FilterOperator) FilterQueryTree(com.linkedin.pinot.common.utils.request.FilterQueryTree) TreeSet(java.util.TreeSet) Pql2CompilationException(com.linkedin.pinot.pql.parsers.Pql2CompilationException)

Aggregations

FilterOperator (com.linkedin.pinot.common.request.FilterOperator)6 FilterQueryTree (com.linkedin.pinot.common.utils.request.FilterQueryTree)5 ArrayList (java.util.ArrayList)3 RangePredicate (com.linkedin.pinot.core.common.predicate.RangePredicate)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 FieldSpec (com.linkedin.pinot.common.data.FieldSpec)1 DataSource (com.linkedin.pinot.core.common.DataSource)1 DataSourceMetadata (com.linkedin.pinot.core.common.DataSourceMetadata)1 Predicate (com.linkedin.pinot.core.common.Predicate)1 EqPredicate (com.linkedin.pinot.core.common.predicate.EqPredicate)1 InPredicate (com.linkedin.pinot.core.common.predicate.InPredicate)1 NEqPredicate (com.linkedin.pinot.core.common.predicate.NEqPredicate)1 NotInPredicate (com.linkedin.pinot.core.common.predicate.NotInPredicate)1 RegexPredicate (com.linkedin.pinot.core.common.predicate.RegexPredicate)1 BaseFilterOperator (com.linkedin.pinot.core.operator.filter.BaseFilterOperator)1 BitmapBasedFilterOperator (com.linkedin.pinot.core.operator.filter.BitmapBasedFilterOperator)1 EmptyFilterOperator (com.linkedin.pinot.core.operator.filter.EmptyFilterOperator)1 MatchEntireSegmentOperator (com.linkedin.pinot.core.operator.filter.MatchEntireSegmentOperator)1 ScanBasedFilterOperator (com.linkedin.pinot.core.operator.filter.ScanBasedFilterOperator)1 SortedInvertedIndexBasedFilterOperator (com.linkedin.pinot.core.operator.filter.SortedInvertedIndexBasedFilterOperator)1