Search in sources :

Example 6 with AndOperator

use of com.linkedin.pinot.core.operator.filter.AndOperator 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)

Aggregations

AndOperator (com.linkedin.pinot.core.operator.filter.AndOperator)6 BaseFilterOperator (com.linkedin.pinot.core.operator.filter.BaseFilterOperator)6 BlockDocIdIterator (com.linkedin.pinot.core.common.BlockDocIdIterator)4 BlockDocIdSet (com.linkedin.pinot.core.common.BlockDocIdSet)4 BaseFilterBlock (com.linkedin.pinot.core.operator.blocks.BaseFilterBlock)4 ArrayList (java.util.ArrayList)4 Test (org.testng.annotations.Test)4 OrOperator (com.linkedin.pinot.core.operator.filter.OrOperator)3 EmptyFilterOperator (com.linkedin.pinot.core.operator.filter.EmptyFilterOperator)2 FilterOperator (com.linkedin.pinot.common.request.FilterOperator)1 Operator (com.linkedin.pinot.core.common.Operator)1 BitmapBasedFilterOperator (com.linkedin.pinot.core.operator.filter.BitmapBasedFilterOperator)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 StarTreeIndexOperator (com.linkedin.pinot.core.operator.filter.StarTreeIndexOperator)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1