Search in sources :

Example 6 with BaseFilterBlock

use of com.linkedin.pinot.core.operator.blocks.BaseFilterBlock 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 7 with BaseFilterBlock

use of com.linkedin.pinot.core.operator.blocks.BaseFilterBlock in project pinot by linkedin.

the class AndOperatorTest method testIntersectionForTwoLists.

@Test
public void testIntersectionForTwoLists() {
    int[] list1 = new int[] { 2, 3, 10, 15, 16, 28 };
    int[] list2 = new int[] { 3, 6, 8, 20, 28 };
    List<BaseFilterOperator> operators = new ArrayList<>();
    operators.add(makeFilterOperator(list1));
    operators.add(makeFilterOperator(list2));
    final AndOperator andOperator = new AndOperator(operators);
    andOperator.open();
    BaseFilterBlock block;
    while ((block = andOperator.getNextBlock()) != null) {
        final BlockDocIdSet blockDocIdSet = block.getBlockDocIdSet();
        final BlockDocIdIterator iterator = blockDocIdSet.iterator();
        int docId;
        while ((docId = iterator.next()) != Constants.EOF) {
        //        System.out.println(docId);
        }
    }
    andOperator.close();
}
Also used : BaseFilterOperator(com.linkedin.pinot.core.operator.filter.BaseFilterOperator) AndOperator(com.linkedin.pinot.core.operator.filter.AndOperator) BlockDocIdSet(com.linkedin.pinot.core.common.BlockDocIdSet) ArrayList(java.util.ArrayList) BaseFilterBlock(com.linkedin.pinot.core.operator.blocks.BaseFilterBlock) BlockDocIdIterator(com.linkedin.pinot.core.common.BlockDocIdIterator) Test(org.testng.annotations.Test)

Example 8 with BaseFilterBlock

use of com.linkedin.pinot.core.operator.blocks.BaseFilterBlock in project pinot by linkedin.

the class ScanBasedFilterOperator method nextFilterBlock.

@Override
public BaseFilterBlock nextFilterBlock(BlockId BlockId) {
    DataSourceMetadata dataSourceMetadata = dataSource.getDataSourceMetadata();
    FilterBlockDocIdSet docIdSet;
    Block nextBlock = dataSource.nextBlock();
    BlockValSet blockValueSet = nextBlock.getBlockValueSet();
    BlockMetadata blockMetadata = nextBlock.getMetadata();
    if (dataSourceMetadata.isSingleValue()) {
        docIdSet = new ScanBasedSingleValueDocIdSet(dataSource.getOperatorName(), blockValueSet, blockMetadata, predicateEvaluator);
    } else {
        docIdSet = new ScanBasedMultiValueDocIdSet(dataSource.getOperatorName(), blockValueSet, blockMetadata, predicateEvaluator);
    }
    if (startDocId != null) {
        docIdSet.setStartDocId(startDocId);
    }
    if (endDocId != null) {
        docIdSet.setEndDocId(endDocId);
    }
    return new ScanBlock(docIdSet);
}
Also used : DataSourceMetadata(com.linkedin.pinot.core.common.DataSourceMetadata) ScanBasedSingleValueDocIdSet(com.linkedin.pinot.core.operator.docidsets.ScanBasedSingleValueDocIdSet) BlockMetadata(com.linkedin.pinot.core.common.BlockMetadata) Block(com.linkedin.pinot.core.common.Block) BaseFilterBlock(com.linkedin.pinot.core.operator.blocks.BaseFilterBlock) BlockValSet(com.linkedin.pinot.core.common.BlockValSet) FilterBlockDocIdSet(com.linkedin.pinot.core.operator.docidsets.FilterBlockDocIdSet) ScanBasedMultiValueDocIdSet(com.linkedin.pinot.core.operator.docidsets.ScanBasedMultiValueDocIdSet)

Example 9 with BaseFilterBlock

use of com.linkedin.pinot.core.operator.blocks.BaseFilterBlock in project pinot by linkedin.

the class AndOperator method nextFilterBlock.

@Override
public BaseFilterBlock nextFilterBlock(BlockId BlockId) {
    List<FilterBlockDocIdSet> blockDocIdSets = new ArrayList<FilterBlockDocIdSet>();
    for (Operator operator : operators) {
        Block block = operator.nextBlock();
        FilterBlockDocIdSet blockDocIdSet = (FilterBlockDocIdSet) block.getBlockDocIdSet();
        blockDocIdSets.add(blockDocIdSet);
    }
    andBlock = new AndBlock(blockDocIdSets);
    return andBlock;
}
Also used : Operator(com.linkedin.pinot.core.common.Operator) AndBlock(com.linkedin.pinot.core.operator.blocks.AndBlock) ArrayList(java.util.ArrayList) AndBlock(com.linkedin.pinot.core.operator.blocks.AndBlock) Block(com.linkedin.pinot.core.common.Block) BaseFilterBlock(com.linkedin.pinot.core.operator.blocks.BaseFilterBlock) FilterBlockDocIdSet(com.linkedin.pinot.core.operator.docidsets.FilterBlockDocIdSet)

Example 10 with BaseFilterBlock

use of com.linkedin.pinot.core.operator.blocks.BaseFilterBlock in project pinot by linkedin.

the class BaseFilterOperator method getNextBlock.

@Override
public final BaseFilterBlock getNextBlock(BlockId blockId) {
    if (nextBlockCallCounter > 0) {
        return null;
    }
    Block nextBlock = nextFilterBlock(new BlockId(0));
    nextBlockCallCounter = nextBlockCallCounter + 1;
    return (BaseFilterBlock) nextBlock;
}
Also used : Block(com.linkedin.pinot.core.common.Block) BaseFilterBlock(com.linkedin.pinot.core.operator.blocks.BaseFilterBlock) BlockId(com.linkedin.pinot.core.common.BlockId) BaseFilterBlock(com.linkedin.pinot.core.operator.blocks.BaseFilterBlock)

Aggregations

BaseFilterBlock (com.linkedin.pinot.core.operator.blocks.BaseFilterBlock)11 ArrayList (java.util.ArrayList)7 BlockDocIdIterator (com.linkedin.pinot.core.common.BlockDocIdIterator)6 BlockDocIdSet (com.linkedin.pinot.core.common.BlockDocIdSet)6 BaseFilterOperator (com.linkedin.pinot.core.operator.filter.BaseFilterOperator)6 Block (com.linkedin.pinot.core.common.Block)5 Test (org.testng.annotations.Test)5 AndOperator (com.linkedin.pinot.core.operator.filter.AndOperator)4 FilterBlockDocIdSet (com.linkedin.pinot.core.operator.docidsets.FilterBlockDocIdSet)3 Operator (com.linkedin.pinot.core.common.Operator)2 OrOperator (com.linkedin.pinot.core.operator.filter.OrOperator)2 BrokerRequest (com.linkedin.pinot.common.request.BrokerRequest)1 FilterQueryTree (com.linkedin.pinot.common.utils.request.FilterQueryTree)1 BlockId (com.linkedin.pinot.core.common.BlockId)1 BlockMetadata (com.linkedin.pinot.core.common.BlockMetadata)1 BlockValSet (com.linkedin.pinot.core.common.BlockValSet)1 DataSourceMetadata (com.linkedin.pinot.core.common.DataSourceMetadata)1 AndBlock (com.linkedin.pinot.core.operator.blocks.AndBlock)1 BitmapBlock (com.linkedin.pinot.core.operator.blocks.BitmapBlock)1 OrBlock (com.linkedin.pinot.core.operator.blocks.OrBlock)1