Search in sources :

Example 1 with BlockValIterator

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

the class IndexSegmentImpl method iterator.

public Iterator<GenericRow> iterator(final int startDocId, final int endDocId) {
    final Map<String, BlockSingleValIterator> singleValIteratorMap = new HashMap<>();
    final Map<String, BlockMultiValIterator> multiValIteratorMap = new HashMap<>();
    for (String column : getColumnNames()) {
        DataSource dataSource = getDataSource(column);
        BlockValIterator iterator = dataSource.getNextBlock().getBlockValueSet().iterator();
        if (dataSource.getDataSourceMetadata().isSingleValue()) {
            singleValIteratorMap.put(column, (BlockSingleValIterator) iterator);
        } else {
            multiValIteratorMap.put(column, (BlockMultiValIterator) iterator);
        }
    }
    return new Iterator<GenericRow>() {

        int docId = startDocId;

        @Override
        public boolean hasNext() {
            return docId < endDocId;
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException();
        }

        @Override
        public GenericRow next() {
            Map<String, Object> map = new HashMap<>();
            for (String column : singleValIteratorMap.keySet()) {
                int dictId = singleValIteratorMap.get(column).nextIntVal();
                Dictionary dictionary = getDictionaryFor(column);
                map.put(column, dictionary.get(dictId));
            }
            for (String column : multiValIteratorMap.keySet()) {
            //TODO:handle multi value
            }
            GenericRow genericRow = new GenericRow();
            genericRow.init(map);
            docId++;
            return genericRow;
        }
    };
}
Also used : Dictionary(com.linkedin.pinot.core.segment.index.readers.Dictionary) HashMap(java.util.HashMap) DataSource(com.linkedin.pinot.core.common.DataSource) GenericRow(com.linkedin.pinot.core.data.GenericRow) BlockMultiValIterator(com.linkedin.pinot.core.common.BlockMultiValIterator) BlockSingleValIterator(com.linkedin.pinot.core.common.BlockSingleValIterator) BlockSingleValIterator(com.linkedin.pinot.core.common.BlockSingleValIterator) Iterator(java.util.Iterator) BlockMultiValIterator(com.linkedin.pinot.core.common.BlockMultiValIterator) BlockValIterator(com.linkedin.pinot.core.common.BlockValIterator) BlockValIterator(com.linkedin.pinot.core.common.BlockValIterator)

Aggregations

BlockMultiValIterator (com.linkedin.pinot.core.common.BlockMultiValIterator)1 BlockSingleValIterator (com.linkedin.pinot.core.common.BlockSingleValIterator)1 BlockValIterator (com.linkedin.pinot.core.common.BlockValIterator)1 DataSource (com.linkedin.pinot.core.common.DataSource)1 GenericRow (com.linkedin.pinot.core.data.GenericRow)1 Dictionary (com.linkedin.pinot.core.segment.index.readers.Dictionary)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1