Search in sources :

Example 26 with Block

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

the class BitmapBasedFilterOperator method nextFilterBlock.

@Override
public BaseFilterBlock nextFilterBlock(BlockId BlockId) {
    InvertedIndexReader invertedIndex = dataSource.getInvertedIndex();
    Block dataSourceBlock = dataSource.nextBlock();
    int[] dictionaryIds;
    boolean exclusion = false;
    switch(predicate.getType()) {
        case EQ:
        case IN:
        case RANGE:
            dictionaryIds = predicateEvaluator.getMatchingDictionaryIds();
            break;
        case NEQ:
        case NOT_IN:
            exclusion = true;
            dictionaryIds = predicateEvaluator.getNonMatchingDictionaryIds();
            break;
        case REGEX:
        default:
            throw new UnsupportedOperationException("Regex is not supported");
    }
    ImmutableRoaringBitmap[] bitmaps = new ImmutableRoaringBitmap[dictionaryIds.length];
    for (int i = 0; i < dictionaryIds.length; i++) {
        bitmaps[i] = invertedIndex.getImmutable(dictionaryIds[i]);
    }
    bitmapBlock = new BitmapBlock(dataSource.getOperatorName(), dataSourceBlock.getMetadata(), startDocId, endDocId, bitmaps, exclusion);
    return bitmapBlock;
}
Also used : InvertedIndexReader(com.linkedin.pinot.core.segment.index.readers.InvertedIndexReader) ImmutableRoaringBitmap(org.roaringbitmap.buffer.ImmutableRoaringBitmap) Block(com.linkedin.pinot.core.common.Block) BitmapBlock(com.linkedin.pinot.core.operator.blocks.BitmapBlock) BaseFilterBlock(com.linkedin.pinot.core.operator.blocks.BaseFilterBlock) BitmapBlock(com.linkedin.pinot.core.operator.blocks.BitmapBlock)

Example 27 with Block

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

the class BaseOperator method nextBlock.

@Override
public final Block nextBlock() {
    long start = System.currentTimeMillis();
    Block ret = getNextBlock();
    long end = System.currentTimeMillis();
    LOGGER.trace("Time spent in {}: {}", getOperatorName(), (end - start));
    TraceContext.logLatency(getOperatorName(), (end - start));
    return ret;
}
Also used : Block(com.linkedin.pinot.core.common.Block)

Example 28 with Block

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

the class BaseOperator method nextBlock.

@Override
public final Block nextBlock(BlockId blockId) {
    long start = System.currentTimeMillis();
    Block ret = getNextBlock(blockId);
    long end = System.currentTimeMillis();
    LOGGER.trace("Time spent in {}: {}", getOperatorName(), (end - start));
    TraceContext.logLatency(getOperatorName(), (end - start));
    return ret;
}
Also used : Block(com.linkedin.pinot.core.common.Block)

Example 29 with Block

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

the class ColumnDataSourceImpl method getNextBlock.

@Override
public Block getNextBlock(BlockId blockId) {
    Block b = null;
    ColumnMetadata columnMetadata = indexContainer.getColumnMetadata();
    if (columnMetadata.isSingleValue()) {
        // TODO: Support sorted index without dictionary.
        if (columnMetadata.hasDictionary() && columnMetadata.isSorted()) {
            b = new SortedSingleValueBlock(blockId, (SortedForwardIndexReader) indexContainer.getForwardIndex(), indexContainer.getDictionary(), columnMetadata);
        } else {
            b = new UnSortedSingleValueBlock(blockId, (SingleColumnSingleValueReader) indexContainer.getForwardIndex(), indexContainer.getDictionary(), columnMetadata);
        }
    } else {
        b = new MultiValueBlock(blockId, (SingleColumnMultiValueReader) indexContainer.getForwardIndex(), indexContainer.getDictionary(), columnMetadata);
    }
    return b;
}
Also used : SingleColumnSingleValueReader(com.linkedin.pinot.core.io.reader.SingleColumnSingleValueReader) UnSortedSingleValueBlock(com.linkedin.pinot.core.operator.blocks.UnSortedSingleValueBlock) ColumnMetadata(com.linkedin.pinot.core.segment.index.ColumnMetadata) SortedForwardIndexReader(com.linkedin.pinot.core.io.reader.impl.SortedForwardIndexReader) SortedSingleValueBlock(com.linkedin.pinot.core.operator.blocks.SortedSingleValueBlock) UnSortedSingleValueBlock(com.linkedin.pinot.core.operator.blocks.UnSortedSingleValueBlock) Block(com.linkedin.pinot.core.common.Block) MultiValueBlock(com.linkedin.pinot.core.operator.blocks.MultiValueBlock) SortedSingleValueBlock(com.linkedin.pinot.core.operator.blocks.SortedSingleValueBlock) UnSortedSingleValueBlock(com.linkedin.pinot.core.operator.blocks.UnSortedSingleValueBlock) MultiValueBlock(com.linkedin.pinot.core.operator.blocks.MultiValueBlock) SingleColumnMultiValueReader(com.linkedin.pinot.core.io.reader.SingleColumnMultiValueReader)

Example 30 with Block

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

the class SegmentDumpTool method doMain.

public void doMain(String[] args) throws Exception {
    CmdLineParser parser = new CmdLineParser(this);
    parser.parseArgument(args);
    File segmentDir = new File(segmentPath);
    SegmentMetadata metadata = new SegmentMetadataImpl(segmentDir);
    // All columns by default
    if (columnNames == null) {
        columnNames = new ArrayList<String>(metadata.getSchema().getColumnNames());
        Collections.sort(columnNames);
    }
    IndexSegment indexSegment = Loaders.IndexSegment.load(segmentDir, ReadMode.mmap);
    Map<String, Dictionary> dictionaries = new HashMap<String, Dictionary>();
    Map<String, BlockSingleValIterator> iterators = new HashMap<String, BlockSingleValIterator>();
    for (String columnName : columnNames) {
        DataSource dataSource = indexSegment.getDataSource(columnName);
        dataSource.open();
        Block block = dataSource.nextBlock();
        BlockValSet blockValSet = block.getBlockValueSet();
        BlockSingleValIterator itr = (BlockSingleValIterator) blockValSet.iterator();
        iterators.put(columnName, itr);
        dictionaries.put(columnName, dataSource.getDictionary());
    }
    System.out.print("Doc\t");
    for (String columnName : columnNames) {
        System.out.print(columnName);
        System.out.print("\t");
    }
    System.out.println();
    for (int i = 0; i < indexSegment.getSegmentMetadata().getTotalDocs(); i++) {
        System.out.print(i);
        System.out.print("\t");
        for (String columnName : columnNames) {
            FieldSpec.DataType columnType = metadata.getSchema().getFieldSpecFor(columnName).getDataType();
            BlockSingleValIterator itr = iterators.get(columnName);
            Integer encodedValue = itr.nextIntVal();
            Object value = dictionaries.get(columnName).get(encodedValue);
            System.out.print(value);
            System.out.print("\t");
        }
        System.out.println();
    }
    if (dumpStarTree) {
        System.out.println();
        File starTreeFile = new File(segmentDir, V1Constants.STAR_TREE_INDEX_FILE);
        StarTreeInterf tree = StarTreeSerDe.fromFile(starTreeFile, ReadMode.mmap);
        tree.printTree();
    }
}
Also used : Dictionary(com.linkedin.pinot.core.segment.index.readers.Dictionary) CmdLineParser(org.kohsuke.args4j.CmdLineParser) HashMap(java.util.HashMap) IndexSegment(com.linkedin.pinot.core.indexsegment.IndexSegment) FieldSpec(com.linkedin.pinot.common.data.FieldSpec) DataSource(com.linkedin.pinot.core.common.DataSource) SegmentMetadata(com.linkedin.pinot.common.segment.SegmentMetadata) BlockSingleValIterator(com.linkedin.pinot.core.common.BlockSingleValIterator) Block(com.linkedin.pinot.core.common.Block) BlockValSet(com.linkedin.pinot.core.common.BlockValSet) StarTreeInterf(com.linkedin.pinot.core.startree.StarTreeInterf) SegmentMetadataImpl(com.linkedin.pinot.core.segment.index.SegmentMetadataImpl) File(java.io.File)

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