Search in sources :

Example 26 with DataSource

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

the class RealtimeSegmentTest method testMetricPredicateWithoutInvIdx.

@Test
public void testMetricPredicateWithoutInvIdx() throws Exception {
    DataSource ds1 = segmentWithoutInvIdx.getDataSource("count");
    List<String> rhs = new ArrayList<String>();
    rhs.add("890662862");
    Predicate predicate = new EqPredicate("count", rhs);
    ScanBasedFilterOperator op = new ScanBasedFilterOperator(predicate, ds1, 0, segmentWithoutInvIdx.getRawDocumentCount() - 1);
    Block b = op.nextBlock();
    BlockDocIdIterator iterator = b.getBlockDocIdSet().iterator();
    DataSource ds2 = segmentWithoutInvIdx.getDataSource("count");
    BlockSingleValIterator blockValIterator = (BlockSingleValIterator) ds2.nextBlock().getBlockValueSet().iterator();
    int docId = iterator.next();
    int counter = 0;
    while (docId != Constants.EOF) {
        blockValIterator.skipTo(docId);
        Assert.assertEquals(ds1.getDictionary().get(blockValIterator.nextIntVal()), 890662862);
        docId = iterator.next();
        counter++;
    }
    Assert.assertEquals(counter, 100000);
}
Also used : BlockSingleValIterator(com.linkedin.pinot.core.common.BlockSingleValIterator) ArrayList(java.util.ArrayList) Block(com.linkedin.pinot.core.common.Block) NEqPredicate(com.linkedin.pinot.core.common.predicate.NEqPredicate) EqPredicate(com.linkedin.pinot.core.common.predicate.EqPredicate) ScanBasedFilterOperator(com.linkedin.pinot.core.operator.filter.ScanBasedFilterOperator) DataSource(com.linkedin.pinot.core.common.DataSource) RangePredicate(com.linkedin.pinot.core.common.predicate.RangePredicate) NEqPredicate(com.linkedin.pinot.core.common.predicate.NEqPredicate) EqPredicate(com.linkedin.pinot.core.common.predicate.EqPredicate) Predicate(com.linkedin.pinot.core.common.Predicate) BlockDocIdIterator(com.linkedin.pinot.core.common.BlockDocIdIterator) Test(org.testng.annotations.Test) RealtimeSegmentImplTest(com.linkedin.pinot.core.realtime.impl.kafka.RealtimeSegmentImplTest)

Example 27 with DataSource

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

the class RealtimeSegmentTest method test1.

@Test
public void test1() throws Exception {
    DataSource ds = segmentWithInvIdx.getDataSource("column1");
    Block b = ds.nextBlock();
    BlockValSet set = b.getBlockValueSet();
    BlockSingleValIterator it = (BlockSingleValIterator) set.iterator();
    BlockMetadata metadata = b.getMetadata();
    while (it.next()) {
        int dicId = it.nextIntVal();
    }
}
Also used : BlockSingleValIterator(com.linkedin.pinot.core.common.BlockSingleValIterator) BlockMetadata(com.linkedin.pinot.core.common.BlockMetadata) Block(com.linkedin.pinot.core.common.Block) BlockValSet(com.linkedin.pinot.core.common.BlockValSet) DataSource(com.linkedin.pinot.core.common.DataSource) Test(org.testng.annotations.Test) RealtimeSegmentImplTest(com.linkedin.pinot.core.realtime.impl.kafka.RealtimeSegmentImplTest)

Example 28 with DataSource

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

the class RealtimeSegmentTest method testRangeMatchFilteringMetricPredicateWithInvIdx.

@Test
public void testRangeMatchFilteringMetricPredicateWithInvIdx() throws Exception {
    DataSource ds1 = segmentWithInvIdx.getDataSource("count");
    List<String> rhs = new ArrayList<String>();
    rhs.add("[0\t\t*)");
    Predicate predicate = new RangePredicate("count", rhs);
    BitmapBasedFilterOperator op = new BitmapBasedFilterOperator(predicate, ds1, 0, segmentWithInvIdx.getRawDocumentCount() - 1);
    Block b = op.nextBlock();
    BlockDocIdIterator iterator = b.getBlockDocIdSet().iterator();
    DataSource ds2 = segmentWithInvIdx.getDataSource("count");
    BlockSingleValIterator blockValIterator = (BlockSingleValIterator) ds2.nextBlock().getBlockValueSet().iterator();
    int docId = iterator.next();
    int counter = 0;
    while (docId != Constants.EOF) {
        blockValIterator.skipTo(docId);
        Assert.assertEquals(ds1.getDictionary().get(blockValIterator.nextIntVal()), 890662862);
        docId = iterator.next();
        counter++;
    }
    Assert.assertEquals(counter, 100000);
}
Also used : RangePredicate(com.linkedin.pinot.core.common.predicate.RangePredicate) BitmapBasedFilterOperator(com.linkedin.pinot.core.operator.filter.BitmapBasedFilterOperator) BlockSingleValIterator(com.linkedin.pinot.core.common.BlockSingleValIterator) ArrayList(java.util.ArrayList) Block(com.linkedin.pinot.core.common.Block) DataSource(com.linkedin.pinot.core.common.DataSource) RangePredicate(com.linkedin.pinot.core.common.predicate.RangePredicate) NEqPredicate(com.linkedin.pinot.core.common.predicate.NEqPredicate) EqPredicate(com.linkedin.pinot.core.common.predicate.EqPredicate) Predicate(com.linkedin.pinot.core.common.Predicate) BlockDocIdIterator(com.linkedin.pinot.core.common.BlockDocIdIterator) Test(org.testng.annotations.Test) RealtimeSegmentImplTest(com.linkedin.pinot.core.realtime.impl.kafka.RealtimeSegmentImplTest)

Aggregations

DataSource (com.linkedin.pinot.core.common.DataSource)28 Block (com.linkedin.pinot.core.common.Block)21 Test (org.testng.annotations.Test)15 BlockSingleValIterator (com.linkedin.pinot.core.common.BlockSingleValIterator)14 Predicate (com.linkedin.pinot.core.common.Predicate)13 ArrayList (java.util.ArrayList)12 BlockDocIdIterator (com.linkedin.pinot.core.common.BlockDocIdIterator)11 EqPredicate (com.linkedin.pinot.core.common.predicate.EqPredicate)11 RealtimeSegmentImplTest (com.linkedin.pinot.core.realtime.impl.kafka.RealtimeSegmentImplTest)10 NEqPredicate (com.linkedin.pinot.core.common.predicate.NEqPredicate)8 RangePredicate (com.linkedin.pinot.core.common.predicate.RangePredicate)8 FieldSpec (com.linkedin.pinot.common.data.FieldSpec)6 BlockMetadata (com.linkedin.pinot.core.common.BlockMetadata)6 BlockValSet (com.linkedin.pinot.core.common.BlockValSet)5 BitmapBasedFilterOperator (com.linkedin.pinot.core.operator.filter.BitmapBasedFilterOperator)5 ScanBasedFilterOperator (com.linkedin.pinot.core.operator.filter.ScanBasedFilterOperator)5 IndexSegmentImpl (com.linkedin.pinot.core.segment.index.IndexSegmentImpl)5 Dictionary (com.linkedin.pinot.core.segment.index.readers.Dictionary)4 HashMap (java.util.HashMap)4 BlockDocIdSet (com.linkedin.pinot.core.common.BlockDocIdSet)3