Search in sources :

Example 16 with BlockDocIdIterator

use of com.linkedin.pinot.core.common.BlockDocIdIterator in project pinot by linkedin.

the class FilterTreeOptimizationTest method testQuery.

/**
   * Helper method to perform the actual testing for the given query.
   * <ul>
   *   <li> Constructs the operator tree with and without alwaysFalse optimizations. </li>
   *   <li> Compares that all docIds filtered by the two operators are identical. </li>
   * </ul>
   * @param query Query to run.
   */
private void testQuery(String query) {
    BrokerRequest brokerRequest = _compiler.compileToBrokerRequest(query);
    FilterQueryTree filterQueryTree = RequestUtils.generateFilterQueryTree(brokerRequest);
    BaseFilterOperator expectedOperator = FilterPlanNode.constructPhysicalOperator(filterQueryTree, _indexSegment, false);
    BaseFilterOperator actualOperator = FilterPlanNode.constructPhysicalOperator(filterQueryTree, _indexSegment, true);
    BaseFilterBlock expectedBlock;
    while ((expectedBlock = expectedOperator.getNextBlock()) != null) {
        BaseFilterBlock actualBlock = actualOperator.getNextBlock();
        Assert.assertNotNull(actualBlock);
        final BlockDocIdSet expectedDocIdSet = expectedBlock.getBlockDocIdSet();
        final BlockDocIdIterator expectedIterator = expectedDocIdSet.iterator();
        final BlockDocIdSet actualDocIdSet = actualBlock.getBlockDocIdSet();
        final BlockDocIdIterator actualIterator = actualDocIdSet.iterator();
        int expectedDocId;
        int actualDocId;
        while (((expectedDocId = expectedIterator.next()) != Constants.EOF) && ((actualDocId = actualIterator.next()) != Constants.EOF)) {
            Assert.assertEquals(actualDocId, expectedDocId);
        }
        Assert.assertTrue(expectedIterator.next() == Constants.EOF);
        Assert.assertTrue(actualIterator.next() == Constants.EOF);
    }
}
Also used : BaseFilterOperator(com.linkedin.pinot.core.operator.filter.BaseFilterOperator) FilterQueryTree(com.linkedin.pinot.common.utils.request.FilterQueryTree) BlockDocIdSet(com.linkedin.pinot.core.common.BlockDocIdSet) BrokerRequest(com.linkedin.pinot.common.request.BrokerRequest) BaseFilterBlock(com.linkedin.pinot.core.operator.blocks.BaseFilterBlock) BlockDocIdIterator(com.linkedin.pinot.core.common.BlockDocIdIterator)

Example 17 with BlockDocIdIterator

use of com.linkedin.pinot.core.common.BlockDocIdIterator in project pinot by linkedin.

the class BaseSumStarTreeIndexTest method computeSumUsingRawDocs.

/**
   * Helper method to compute the sums using raw index.
   *  @param metricNames
   * @param brokerRequest
   */
private Map<String, double[]> computeSumUsingRawDocs(IndexSegment segment, List<String> metricNames, BrokerRequest brokerRequest) {
    FilterPlanNode planNode = new FilterPlanNode(segment, brokerRequest);
    Operator rawOperator = planNode.run();
    BlockDocIdIterator rawDocIdIterator = rawOperator.nextBlock().getBlockDocIdSet().iterator();
    List<String> groupByColumns = Collections.EMPTY_LIST;
    if (brokerRequest.isSetAggregationsInfo() && brokerRequest.isSetGroupBy()) {
        groupByColumns = brokerRequest.getGroupBy().getColumns();
    }
    return computeSum(segment, rawDocIdIterator, metricNames, groupByColumns);
}
Also used : StarTreeIndexOperator(com.linkedin.pinot.core.operator.filter.StarTreeIndexOperator) Operator(com.linkedin.pinot.core.common.Operator) FilterPlanNode(com.linkedin.pinot.core.plan.FilterPlanNode) BlockDocIdIterator(com.linkedin.pinot.core.common.BlockDocIdIterator)

Example 18 with BlockDocIdIterator

use of com.linkedin.pinot.core.common.BlockDocIdIterator 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)

Example 19 with BlockDocIdIterator

use of com.linkedin.pinot.core.common.BlockDocIdIterator in project pinot by linkedin.

the class RealtimeSegmentTest method testNoRangeMatchFilteringMetricPredicateWithInvIdx.

@Test
public void testNoRangeMatchFilteringMetricPredicateWithInvIdx() throws Exception {
    DataSource ds1 = segmentWithInvIdx.getDataSource("count");
    List<String> rhs = new ArrayList<String>();
    rhs.add("[0\t\t100)");
    Predicate predicate = new RangePredicate("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 : RangePredicate(com.linkedin.pinot.core.common.predicate.RangePredicate) 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 20 with BlockDocIdIterator

use of com.linkedin.pinot.core.common.BlockDocIdIterator in project pinot by linkedin.

the class RealtimeSegmentTest method testMetricPredicateWithoutInvIdx.

@Test
public void testMetricPredicateWithoutInvIdx() throws Exception {
    DataSource ds1 = segmentWithoutInvIdx.getDataSource("count");
    List<String> rhs = new ArrayList<String>();
    rhs.add("890662862");
    Predicate predicate = new EqPredicate("count", rhs);
    ScanBasedFilterOperator op = new ScanBasedFilterOperator(predicate, ds1, 0, segmentWithoutInvIdx.getRawDocumentCount() - 1);
    Block b = op.nextBlock();
    BlockDocIdIterator iterator = b.getBlockDocIdSet().iterator();
    DataSource ds2 = segmentWithoutInvIdx.getDataSource("count");
    BlockSingleValIterator blockValIterator = (BlockSingleValIterator) ds2.nextBlock().getBlockValueSet().iterator();
    int docId = iterator.next();
    int counter = 0;
    while (docId != Constants.EOF) {
        blockValIterator.skipTo(docId);
        Assert.assertEquals(ds1.getDictionary().get(blockValIterator.nextIntVal()), 890662862);
        docId = iterator.next();
        counter++;
    }
    Assert.assertEquals(counter, 100000);
}
Also used : BlockSingleValIterator(com.linkedin.pinot.core.common.BlockSingleValIterator) ArrayList(java.util.ArrayList) Block(com.linkedin.pinot.core.common.Block) NEqPredicate(com.linkedin.pinot.core.common.predicate.NEqPredicate) EqPredicate(com.linkedin.pinot.core.common.predicate.EqPredicate) 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

BlockDocIdIterator (com.linkedin.pinot.core.common.BlockDocIdIterator)33 ArrayList (java.util.ArrayList)28 Test (org.testng.annotations.Test)24 BlockDocIdSet (com.linkedin.pinot.core.common.BlockDocIdSet)14 Block (com.linkedin.pinot.core.common.Block)13 DataSource (com.linkedin.pinot.core.common.DataSource)11 Predicate (com.linkedin.pinot.core.common.Predicate)11 EqPredicate (com.linkedin.pinot.core.common.predicate.EqPredicate)11 NEqPredicate (com.linkedin.pinot.core.common.predicate.NEqPredicate)8 RangePredicate (com.linkedin.pinot.core.common.predicate.RangePredicate)8 BaseFilterBlock (com.linkedin.pinot.core.operator.blocks.BaseFilterBlock)8 BaseFilterOperator (com.linkedin.pinot.core.operator.filter.BaseFilterOperator)8 RealtimeSegmentImplTest (com.linkedin.pinot.core.realtime.impl.kafka.RealtimeSegmentImplTest)8 IntPair (com.linkedin.pinot.common.utils.Pairs.IntPair)7 SortedDocIdSet (com.linkedin.pinot.core.operator.docidsets.SortedDocIdSet)5 MutableRoaringBitmap (org.roaringbitmap.buffer.MutableRoaringBitmap)5 BlockSingleValIterator (com.linkedin.pinot.core.common.BlockSingleValIterator)4 AndOperator (com.linkedin.pinot.core.operator.filter.AndOperator)4 BitmapBasedFilterOperator (com.linkedin.pinot.core.operator.filter.BitmapBasedFilterOperator)4 OrOperator (com.linkedin.pinot.core.operator.filter.OrOperator)4