Search in sources :

Example 21 with Block

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

the class OrOperatorTest 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 OrOperator orOperator = new OrOperator(operators);
    orOperator.open();
    Block block;
    TreeSet<Integer> set = new TreeSet<Integer>();
    set.addAll(Lists.newArrayList(ArrayUtils.toObject(list1)));
    set.addAll(Lists.newArrayList(ArrayUtils.toObject(list2)));
    Iterator<Integer> expectedIterator = set.iterator();
    while ((block = orOperator.nextBlock()) != null) {
        final BlockDocIdSet blockDocIdSet = block.getBlockDocIdSet();
        final BlockDocIdIterator iterator = blockDocIdSet.iterator();
        int docId;
        while ((docId = iterator.next()) != Constants.EOF) {
            Assert.assertEquals(expectedIterator.next().intValue(), docId);
        }
    }
    orOperator.close();
}
Also used : OrOperator(com.linkedin.pinot.core.operator.filter.OrOperator) ArrayList(java.util.ArrayList) 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) Block(com.linkedin.pinot.core.common.Block) BaseFilterBlock(com.linkedin.pinot.core.operator.blocks.BaseFilterBlock) Test(org.testng.annotations.Test)

Example 22 with Block

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

the class OrOperatorTest 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<>();
    operators.add(makeFilterOperator(list1));
    operators.add(makeFilterOperator(list2));
    operators.add(makeFilterOperator(list3));
    final OrOperator orOperator = new OrOperator(operators);
    orOperator.open();
    Block block;
    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();
    while ((block = orOperator.nextBlock()) != null) {
        final BlockDocIdSet blockDocIdSet = block.getBlockDocIdSet();
        final BlockDocIdIterator iterator = blockDocIdSet.iterator();
        int docId;
        while ((docId = iterator.next()) != Constants.EOF) {
            Assert.assertEquals(expectedIterator.next().intValue(), docId);
        }
    }
    orOperator.close();
}
Also used : OrOperator(com.linkedin.pinot.core.operator.filter.OrOperator) ArrayList(java.util.ArrayList) 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) Block(com.linkedin.pinot.core.common.Block) BaseFilterBlock(com.linkedin.pinot.core.operator.blocks.BaseFilterBlock) Test(org.testng.annotations.Test)

Example 23 with Block

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

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

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

Block (com.linkedin.pinot.core.common.Block)35 DataSource (com.linkedin.pinot.core.common.DataSource)21 Test (org.testng.annotations.Test)17 ArrayList (java.util.ArrayList)16 BlockDocIdIterator (com.linkedin.pinot.core.common.BlockDocIdIterator)13 BlockSingleValIterator (com.linkedin.pinot.core.common.BlockSingleValIterator)12 Predicate (com.linkedin.pinot.core.common.Predicate)11 EqPredicate (com.linkedin.pinot.core.common.predicate.EqPredicate)11 RealtimeSegmentImplTest (com.linkedin.pinot.core.realtime.impl.kafka.RealtimeSegmentImplTest)10 BlockMetadata (com.linkedin.pinot.core.common.BlockMetadata)8 NEqPredicate (com.linkedin.pinot.core.common.predicate.NEqPredicate)8 RangePredicate (com.linkedin.pinot.core.common.predicate.RangePredicate)8 BlockValSet (com.linkedin.pinot.core.common.BlockValSet)7 BaseFilterBlock (com.linkedin.pinot.core.operator.blocks.BaseFilterBlock)7 BlockDocIdSet (com.linkedin.pinot.core.common.BlockDocIdSet)6 FieldSpec (com.linkedin.pinot.common.data.FieldSpec)5 IndexSegmentImpl (com.linkedin.pinot.core.segment.index.IndexSegmentImpl)5 BitmapBasedFilterOperator (com.linkedin.pinot.core.operator.filter.BitmapBasedFilterOperator)4 ScanBasedFilterOperator (com.linkedin.pinot.core.operator.filter.ScanBasedFilterOperator)4 BlockMultiValIterator (com.linkedin.pinot.core.common.BlockMultiValIterator)3