Search in sources :

Example 16 with IndexKey

use of org.apache.carbondata.core.datastore.IndexKey in project carbondata by apache.

the class InMemoryBTreeIndex method getDataBlocksOfIndex.

/**
   * get data blocks of given btree
   */
private List<DataRefNode> getDataBlocksOfIndex(AbstractIndex abstractIndex) {
    List<DataRefNode> blocks = new LinkedList<DataRefNode>();
    SegmentProperties segmentProperties = abstractIndex.getSegmentProperties();
    try {
        IndexKey startIndexKey = FilterUtil.prepareDefaultStartIndexKey(segmentProperties);
        IndexKey endIndexKey = FilterUtil.prepareDefaultEndIndexKey(segmentProperties);
        // Add all blocks of btree into result
        DataRefNodeFinder blockFinder = new BTreeDataRefNodeFinder(segmentProperties.getEachDimColumnValueSize(), segmentProperties.getNumberOfSortColumns(), segmentProperties.getNumberOfNoDictSortColumns());
        DataRefNode startBlock = blockFinder.findFirstDataBlock(abstractIndex.getDataRefNode(), startIndexKey);
        DataRefNode endBlock = blockFinder.findLastDataBlock(abstractIndex.getDataRefNode(), endIndexKey);
        while (startBlock != endBlock) {
            blocks.add(startBlock);
            startBlock = startBlock.getNextDataRefNode();
        }
        blocks.add(endBlock);
    } catch (KeyGenException e) {
        LOG.error("Could not generate start key", e);
    }
    return blocks;
}
Also used : IndexKey(org.apache.carbondata.core.datastore.IndexKey) KeyGenException(org.apache.carbondata.core.keygenerator.KeyGenException) DataRefNode(org.apache.carbondata.core.datastore.DataRefNode) SegmentProperties(org.apache.carbondata.core.datastore.block.SegmentProperties) BTreeDataRefNodeFinder(org.apache.carbondata.core.datastore.impl.btree.BTreeDataRefNodeFinder) DataRefNodeFinder(org.apache.carbondata.core.datastore.DataRefNodeFinder) LinkedList(java.util.LinkedList) BTreeDataRefNodeFinder(org.apache.carbondata.core.datastore.impl.btree.BTreeDataRefNodeFinder)

Aggregations

IndexKey (org.apache.carbondata.core.datastore.IndexKey)16 DataRefNode (org.apache.carbondata.core.datastore.DataRefNode)9 DataRefNodeFinder (org.apache.carbondata.core.datastore.DataRefNodeFinder)9 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)5 BTreeBuilderInfo (org.apache.carbondata.core.datastore.BTreeBuilderInfo)5 BtreeBuilder (org.apache.carbondata.core.datastore.BtreeBuilder)5 SegmentProperties (org.apache.carbondata.core.datastore.block.SegmentProperties)5 DataFileFooter (org.apache.carbondata.core.metadata.blocklet.DataFileFooter)5 BTreeDataRefNodeFinder (org.apache.carbondata.core.datastore.impl.btree.BTreeDataRefNodeFinder)4 KeyGenException (org.apache.carbondata.core.keygenerator.KeyGenException)4 KeyGenerator (org.apache.carbondata.core.keygenerator.KeyGenerator)4 ByteBuffer (java.nio.ByteBuffer)3 MultiDimKeyVarLengthGenerator (org.apache.carbondata.core.keygenerator.mdkey.MultiDimKeyVarLengthGenerator)3 MockUp (mockit.MockUp)2 AbstractDictionaryCacheTest (org.apache.carbondata.core.cache.dictionary.AbstractDictionaryCacheTest)2 Encoding (org.apache.carbondata.core.metadata.encoder.Encoding)2 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1