Search in sources :

Example 1 with BaseFilterBlock

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

the class OrOperator 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);
    }
    orBlock = new OrBlock(blockDocIdSets);
    return orBlock;
}
Also used : Operator(com.linkedin.pinot.core.common.Operator) OrBlock(com.linkedin.pinot.core.operator.blocks.OrBlock) ArrayList(java.util.ArrayList) OrBlock(com.linkedin.pinot.core.operator.blocks.OrBlock) Block(com.linkedin.pinot.core.common.Block) BaseFilterBlock(com.linkedin.pinot.core.operator.blocks.BaseFilterBlock) FilterBlockDocIdSet(com.linkedin.pinot.core.operator.docidsets.FilterBlockDocIdSet)

Example 2 with BaseFilterBlock

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

the class AndOperatorTest method testIntersectionForThreeLists.

@Test
public void testIntersectionForThreeLists() {
    int[] list1 = new int[] { 2, 3, 6, 10, 15, 16, 28 };
    int[] list2 = new int[] { 3, 6, 8, 20, 28 };
    int[] list3 = new int[] { 1, 2, 3, 6, 30 };
    List<BaseFilterOperator> operators = new ArrayList<BaseFilterOperator>();
    operators.add(makeFilterOperator(list1));
    operators.add(makeFilterOperator(list2));
    operators.add(makeFilterOperator(list3));
    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 3 with BaseFilterBlock

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

the class AndOperatorTest method testComplexWithOr.

@Test
public void testComplexWithOr() {
    int[] list1 = new int[] { 2, 3, 6, 10, 15, 16, 28 };
    int[] list2 = new int[] { 3, 6, 8, 20, 28 };
    int[] list3 = new int[] { 1, 2, 3, 6, 30 };
    List<BaseFilterOperator> operators = new ArrayList<>();
    operators.add(makeFilterOperator(list3));
    operators.add(makeFilterOperator(list2));
    final OrOperator orOperator = new OrOperator(operators);
    List<BaseFilterOperator> operators1 = new ArrayList<>();
    operators1.add(orOperator);
    operators1.add(makeFilterOperator(list1));
    final AndOperator andOperator = new AndOperator(operators1);
    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 : OrOperator(com.linkedin.pinot.core.operator.filter.OrOperator) 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 4 with BaseFilterBlock

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

the class AndOperatorTest method testComplex.

@Test
public void testComplex() {
    int[] list1 = new int[] { 2, 3, 6, 10, 15, 16, 28 };
    int[] list2 = new int[] { 3, 6, 8, 20, 28 };
    int[] list3 = new int[] { 1, 2, 3, 6, 30 };
    List<BaseFilterOperator> operators = new ArrayList<>();
    operators.add(makeFilterOperator(list1));
    operators.add(makeFilterOperator(list2));
    final AndOperator andOperator1 = new AndOperator(operators);
    List<BaseFilterOperator> operators1 = new ArrayList<>();
    operators1.add(andOperator1);
    operators1.add(makeFilterOperator(list3));
    final AndOperator andOperator = new AndOperator(operators1);
    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 5 with BaseFilterBlock

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

the class OrOperatorTest method testComplex.

@Test
public void testComplex() {
    int[] list1 = new int[] { 2, 3, 6, 10, 15, 16, 28 };
    int[] list2 = new int[] { 3, 6, 8, 20, 28 };
    int[] list3 = new int[] { 1, 2, 3, 6, 30 };
    TreeSet<Integer> set = new TreeSet<Integer>();
    set.addAll(Lists.newArrayList(ArrayUtils.toObject(list1)));
    set.addAll(Lists.newArrayList(ArrayUtils.toObject(list2)));
    set.addAll(Lists.newArrayList(ArrayUtils.toObject(list3)));
    Iterator<Integer> expectedIterator = set.iterator();
    List<BaseFilterOperator> operators = new ArrayList<>();
    operators.add(makeFilterOperator(list1));
    operators.add(makeFilterOperator(list2));
    final OrOperator orOperator1 = new OrOperator(operators);
    List<BaseFilterOperator> operators1 = new ArrayList<>();
    operators1.add(orOperator1);
    operators1.add(makeFilterOperator(list3));
    final OrOperator orOperator = new OrOperator(operators1);
    orOperator.open();
    BaseFilterBlock block;
    while ((block = orOperator.getNextBlock()) != null) {
        final BlockDocIdSet blockDocIdSet = block.getBlockDocIdSet();
        final BlockDocIdIterator iterator = blockDocIdSet.iterator();
        int docId;
        while ((docId = iterator.next()) != Constants.EOF) {
            //        System.out.println(docId);
            Assert.assertEquals(expectedIterator.next().intValue(), docId);
        }
    }
    orOperator.close();
}
Also used : OrOperator(com.linkedin.pinot.core.operator.filter.OrOperator) ArrayList(java.util.ArrayList) BaseFilterBlock(com.linkedin.pinot.core.operator.blocks.BaseFilterBlock) BlockDocIdIterator(com.linkedin.pinot.core.common.BlockDocIdIterator) BaseFilterOperator(com.linkedin.pinot.core.operator.filter.BaseFilterOperator) TreeSet(java.util.TreeSet) BlockDocIdSet(com.linkedin.pinot.core.common.BlockDocIdSet) Test(org.testng.annotations.Test)

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