Search in sources :

Example 31 with Block

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

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

the class ChunkIndexCreationDriverImplTest method test3.

@Test
public void test3() throws Exception {
    final IndexSegmentImpl segment = (IndexSegmentImpl) Loaders.IndexSegment.load(INDEX_DIR.listFiles()[0], ReadMode.mmap);
    final DataSource ds = segment.getDataSource("column7");
    final Block bl = ds.nextBlock();
    final BlockValSet valSet = bl.getBlockValueSet();
    final int maxValue = ((SegmentMetadataImpl) segment.getSegmentMetadata()).getColumnMetadataFor("column7").getMaxNumberOfMultiValues();
    final BlockMultiValIterator it = (BlockMultiValIterator) valSet.iterator();
    while (it.hasNext()) {
        final int[] entry = new int[maxValue];
        it.nextIntVal(entry);
        LOGGER.trace(Arrays.toString(entry));
    }
}
Also used : BlockMultiValIterator(com.linkedin.pinot.core.common.BlockMultiValIterator) IndexSegmentImpl(com.linkedin.pinot.core.segment.index.IndexSegmentImpl) 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)

Example 33 with Block

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

Example 34 with Block

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

the class ChunkIndexCreationDriverImplTest method test2.

@Test
public void test2() throws Exception {
    final IndexSegmentImpl segment = (IndexSegmentImpl) Loaders.IndexSegment.load(INDEX_DIR.listFiles()[0], ReadMode.mmap);
    //    System.out.println("INdex dir:" + INDEX_DIR);
    final DataSource ds = segment.getDataSource("column1");
    final Block bl = ds.nextBlock();
    final BlockValSet valSet = bl.getBlockValueSet();
    final BlockSingleValIterator it = (BlockSingleValIterator) valSet.iterator();
    // TODO: FIXME - load segment with known data and verify that it exists
    while (it.hasNext()) {
        LOGGER.trace(Integer.toString(it.nextIntVal()));
    }
}
Also used : IndexSegmentImpl(com.linkedin.pinot.core.segment.index.IndexSegmentImpl) BlockSingleValIterator(com.linkedin.pinot.core.common.BlockSingleValIterator) 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)

Example 35 with Block

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

the class ChunkIndexCreationDriverImplTest method test6.

@Test(enabled = false)
public void test6() throws Exception {
    final IndexSegmentImpl segment = (IndexSegmentImpl) Loaders.IndexSegment.load(INDEX_DIR.listFiles()[0], ReadMode.mmap);
    final ImmutableDictionaryReader d = segment.getDictionaryFor("column7");
    final List<String> rhs = new ArrayList<String>();
    rhs.add(d.get(new Random().nextInt(d.length())).toString());
    final Predicate p = new EqPredicate("column7", rhs);
    final DataSource ds = segment.getDataSource("column7", 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 : ImmutableDictionaryReader(com.linkedin.pinot.core.segment.index.readers.ImmutableDictionaryReader) ArrayList(java.util.ArrayList) 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) IndexSegmentImpl(com.linkedin.pinot.core.segment.index.IndexSegmentImpl) Random(java.util.Random) BlockDocIdSet(com.linkedin.pinot.core.common.BlockDocIdSet) Block(com.linkedin.pinot.core.common.Block) Test(org.testng.annotations.Test)

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