Search in sources :

Example 6 with BlockDocIdSet

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

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

Example 8 with BlockDocIdSet

use of com.linkedin.pinot.core.common.BlockDocIdSet 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 9 with BlockDocIdSet

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

the class OperatorSize method size.

public static int size(Operator operator) {
    Block block;
    int count = 0;
    operator.open();
    while ((block = operator.nextBlock()) != null) {
        BlockDocIdSet docIdSet = block.getBlockDocIdSet();
        count += size(docIdSet);
    }
    operator.close();
    System.out.println("count = " + count);
    return count;
}
Also used : BlockDocIdSet(com.linkedin.pinot.core.common.BlockDocIdSet) Block(com.linkedin.pinot.core.common.Block)

Example 10 with BlockDocIdSet

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

the class ChunkIndexCreationDriverImplTest method test5.

@Test(enabled = false)
public void test5() throws Exception {
    final IndexSegmentImpl segment = (IndexSegmentImpl) Loaders.IndexSegment.load(INDEX_DIR.listFiles()[0], ReadMode.mmap);
    final List<String> rhs = new ArrayList<String>();
    rhs.add("-100");
    final Predicate p = new EqPredicate("column1", rhs);
    final DataSource ds = segment.getDataSource("column1", p);
    final Block bl = ds.nextBlock();
    final BlockDocIdSet idSet = bl.getBlockDocIdSet();
    final BlockDocIdIterator it = idSet.iterator();
    int docId = it.next();
    final StringBuilder b = new StringBuilder();
    while (docId != Constants.EOF) {
        b.append(docId + ",");
        docId = it.next();
    }
//    System.out.println(b.toString());
}
Also used : IndexSegmentImpl(com.linkedin.pinot.core.segment.index.IndexSegmentImpl) BlockDocIdSet(com.linkedin.pinot.core.common.BlockDocIdSet) ArrayList(java.util.ArrayList) Block(com.linkedin.pinot.core.common.Block) EqPredicate(com.linkedin.pinot.core.common.predicate.EqPredicate) EqPredicate(com.linkedin.pinot.core.common.predicate.EqPredicate) Predicate(com.linkedin.pinot.core.common.Predicate) DataSource(com.linkedin.pinot.core.common.DataSource) BlockDocIdIterator(com.linkedin.pinot.core.common.BlockDocIdIterator) Test(org.testng.annotations.Test)

Aggregations

BlockDocIdSet (com.linkedin.pinot.core.common.BlockDocIdSet)15 BlockDocIdIterator (com.linkedin.pinot.core.common.BlockDocIdIterator)14 ArrayList (java.util.ArrayList)13 Test (org.testng.annotations.Test)10 BaseFilterBlock (com.linkedin.pinot.core.operator.blocks.BaseFilterBlock)8 BaseFilterOperator (com.linkedin.pinot.core.operator.filter.BaseFilterOperator)8 Block (com.linkedin.pinot.core.common.Block)6 AndOperator (com.linkedin.pinot.core.operator.filter.AndOperator)4 OrOperator (com.linkedin.pinot.core.operator.filter.OrOperator)4 DataSource (com.linkedin.pinot.core.common.DataSource)3 Predicate (com.linkedin.pinot.core.common.Predicate)3 EqPredicate (com.linkedin.pinot.core.common.predicate.EqPredicate)3 IndexSegmentImpl (com.linkedin.pinot.core.segment.index.IndexSegmentImpl)3 TreeSet (java.util.TreeSet)3 ImmutableRoaringBitmap (org.roaringbitmap.buffer.ImmutableRoaringBitmap)3 MutableRoaringBitmap (org.roaringbitmap.buffer.MutableRoaringBitmap)3 IntPair (com.linkedin.pinot.common.utils.Pairs.IntPair)2 AndDocIdIterator (com.linkedin.pinot.core.operator.dociditerators.AndDocIdIterator)2 BitmapDocIdIterator (com.linkedin.pinot.core.operator.dociditerators.BitmapDocIdIterator)2 RangelessBitmapDocIdIterator (com.linkedin.pinot.core.operator.dociditerators.RangelessBitmapDocIdIterator)2