Search in sources :

Example 1 with NEqPredicate

use of com.linkedin.pinot.core.common.predicate.NEqPredicate in project pinot by linkedin.

the class Predicate method newPredicate.

public static Predicate newPredicate(FilterQueryTree filterQueryTree) {
    assert (filterQueryTree.getChildren() == null) || filterQueryTree.getChildren().isEmpty();
    final FilterOperator filterType = filterQueryTree.getOperator();
    final String column = filterQueryTree.getColumn();
    final List<String> value = filterQueryTree.getValue();
    Predicate predicate = null;
    switch(filterType) {
        case EQUALITY:
            predicate = new EqPredicate(column, value);
            break;
        case RANGE:
            predicate = new RangePredicate(column, value);
            break;
        case REGEX:
            predicate = new RegexPredicate(column, value);
            break;
        case NOT:
            predicate = new NEqPredicate(column, value);
            break;
        case NOT_IN:
            predicate = new NotInPredicate(column, value);
            break;
        case IN:
            predicate = new InPredicate(column, value);
            break;
        default:
            throw new UnsupportedOperationException("Unsupported filterType:" + filterType);
    }
    return predicate;
}
Also used : FilterOperator(com.linkedin.pinot.common.request.FilterOperator) RangePredicate(com.linkedin.pinot.core.common.predicate.RangePredicate) NEqPredicate(com.linkedin.pinot.core.common.predicate.NEqPredicate) RegexPredicate(com.linkedin.pinot.core.common.predicate.RegexPredicate) NEqPredicate(com.linkedin.pinot.core.common.predicate.NEqPredicate) EqPredicate(com.linkedin.pinot.core.common.predicate.EqPredicate) InPredicate(com.linkedin.pinot.core.common.predicate.InPredicate) NotInPredicate(com.linkedin.pinot.core.common.predicate.NotInPredicate) RegexPredicate(com.linkedin.pinot.core.common.predicate.RegexPredicate) RangePredicate(com.linkedin.pinot.core.common.predicate.RangePredicate) NEqPredicate(com.linkedin.pinot.core.common.predicate.NEqPredicate) InPredicate(com.linkedin.pinot.core.common.predicate.InPredicate) EqPredicate(com.linkedin.pinot.core.common.predicate.EqPredicate) NotInPredicate(com.linkedin.pinot.core.common.predicate.NotInPredicate) NotInPredicate(com.linkedin.pinot.core.common.predicate.NotInPredicate)

Example 2 with NEqPredicate

use of com.linkedin.pinot.core.common.predicate.NEqPredicate in project pinot by linkedin.

the class RealtimeSegmentTest method testNoMatchFilteringMetricPredicateWithInvIdx.

@Test
public void testNoMatchFilteringMetricPredicateWithInvIdx() throws Exception {
    DataSource ds1 = segmentWithInvIdx.getDataSource("count");
    List<String> rhs = new ArrayList<String>();
    rhs.add("890662862");
    Predicate predicate = new NEqPredicate("count", rhs);
    BitmapBasedFilterOperator op = new BitmapBasedFilterOperator(predicate, ds1, 0, segmentWithInvIdx.getRawDocumentCount() - 1);
    Block b = op.nextBlock();
    BlockDocIdIterator iterator = b.getBlockDocIdSet().iterator();
    int counter = 0;
    int docId = iterator.next();
    while (docId != Constants.EOF) {
        // shouldn't reach here.
        Assert.assertTrue(false);
        docId = iterator.next();
        counter++;
    }
    Assert.assertEquals(counter, 0);
}
Also used : NEqPredicate(com.linkedin.pinot.core.common.predicate.NEqPredicate) BitmapBasedFilterOperator(com.linkedin.pinot.core.operator.filter.BitmapBasedFilterOperator) ArrayList(java.util.ArrayList) Block(com.linkedin.pinot.core.common.Block) DataSource(com.linkedin.pinot.core.common.DataSource) RangePredicate(com.linkedin.pinot.core.common.predicate.RangePredicate) NEqPredicate(com.linkedin.pinot.core.common.predicate.NEqPredicate) EqPredicate(com.linkedin.pinot.core.common.predicate.EqPredicate) Predicate(com.linkedin.pinot.core.common.Predicate) BlockDocIdIterator(com.linkedin.pinot.core.common.BlockDocIdIterator) Test(org.testng.annotations.Test) RealtimeSegmentImplTest(com.linkedin.pinot.core.realtime.impl.kafka.RealtimeSegmentImplTest)

Example 3 with NEqPredicate

use of com.linkedin.pinot.core.common.predicate.NEqPredicate in project pinot by linkedin.

the class RealtimeSegmentTest method testNoMatchFilteringMetricPredicateWithoutInvIdx.

@Test
public void testNoMatchFilteringMetricPredicateWithoutInvIdx() throws Exception {
    DataSource ds1 = segmentWithoutInvIdx.getDataSource("count");
    List<String> rhs = new ArrayList<String>();
    rhs.add("890662862");
    Predicate predicate = new NEqPredicate("count", rhs);
    ScanBasedFilterOperator op = new ScanBasedFilterOperator(predicate, ds1, 0, segmentWithoutInvIdx.getRawDocumentCount() - 1);
    Block b = op.nextBlock();
    BlockDocIdIterator iterator = b.getBlockDocIdSet().iterator();
    int counter = 0;
    int docId = iterator.next();
    while (docId != Constants.EOF) {
        // shouldn't reach here.
        Assert.assertTrue(false);
        docId = iterator.next();
        counter++;
    }
    Assert.assertEquals(counter, 0);
}
Also used : NEqPredicate(com.linkedin.pinot.core.common.predicate.NEqPredicate) ArrayList(java.util.ArrayList) Block(com.linkedin.pinot.core.common.Block) ScanBasedFilterOperator(com.linkedin.pinot.core.operator.filter.ScanBasedFilterOperator) DataSource(com.linkedin.pinot.core.common.DataSource) RangePredicate(com.linkedin.pinot.core.common.predicate.RangePredicate) NEqPredicate(com.linkedin.pinot.core.common.predicate.NEqPredicate) EqPredicate(com.linkedin.pinot.core.common.predicate.EqPredicate) Predicate(com.linkedin.pinot.core.common.Predicate) BlockDocIdIterator(com.linkedin.pinot.core.common.BlockDocIdIterator) Test(org.testng.annotations.Test) RealtimeSegmentImplTest(com.linkedin.pinot.core.realtime.impl.kafka.RealtimeSegmentImplTest)

Aggregations

EqPredicate (com.linkedin.pinot.core.common.predicate.EqPredicate)3 NEqPredicate (com.linkedin.pinot.core.common.predicate.NEqPredicate)3 RangePredicate (com.linkedin.pinot.core.common.predicate.RangePredicate)3 Block (com.linkedin.pinot.core.common.Block)2 BlockDocIdIterator (com.linkedin.pinot.core.common.BlockDocIdIterator)2 DataSource (com.linkedin.pinot.core.common.DataSource)2 Predicate (com.linkedin.pinot.core.common.Predicate)2 RealtimeSegmentImplTest (com.linkedin.pinot.core.realtime.impl.kafka.RealtimeSegmentImplTest)2 ArrayList (java.util.ArrayList)2 Test (org.testng.annotations.Test)2 FilterOperator (com.linkedin.pinot.common.request.FilterOperator)1 InPredicate (com.linkedin.pinot.core.common.predicate.InPredicate)1 NotInPredicate (com.linkedin.pinot.core.common.predicate.NotInPredicate)1 RegexPredicate (com.linkedin.pinot.core.common.predicate.RegexPredicate)1 BitmapBasedFilterOperator (com.linkedin.pinot.core.operator.filter.BitmapBasedFilterOperator)1 ScanBasedFilterOperator (com.linkedin.pinot.core.operator.filter.ScanBasedFilterOperator)1