Search in sources :

Example 6 with BTreeBuilderInfo

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

the class BTreeBlockFinderTest method testBtreeSearchIsWorkingAndGivingPorperBlockletWithNoDictionary1.

@Test
public void testBtreeSearchIsWorkingAndGivingPorperBlockletWithNoDictionary1() {
    BtreeBuilder builder = new BlockBTreeBuilder();
    List<DataFileFooter> footerList = getFileFooterListWithOnlyNoDictionaryKey();
    BTreeBuilderInfo infos = new BTreeBuilderInfo(footerList, null);
    builder.build(infos);
    DataRefNode dataBlock = builder.get();
    assertTrue(dataBlock != null);
    DataRefNodeFinder finder = new BTreeDataRefNodeFinder(new int[] { -1 }, 1, 1);
    ByteBuffer buffer = ByteBuffer.allocate(4 + 2);
    buffer.rewind();
    buffer.putShort((short) 1);
    buffer.putInt(12);
    buffer.array();
    IndexKey key = new IndexKey(null, buffer.array());
    DataRefNode findFirstBlock = finder.findFirstDataBlock(dataBlock, key);
    assertEquals(1, findFirstBlock.nodeNumber());
    DataRefNode findLastBlock = finder.findLastDataBlock(dataBlock, key);
    assertEquals(1, findLastBlock.nodeNumber());
}
Also used : IndexKey(org.apache.carbondata.core.datastore.IndexKey) DataFileFooter(org.apache.carbondata.core.metadata.blocklet.DataFileFooter) BTreeBuilderInfo(org.apache.carbondata.core.datastore.BTreeBuilderInfo) DataRefNode(org.apache.carbondata.core.datastore.DataRefNode) DataRefNodeFinder(org.apache.carbondata.core.datastore.DataRefNodeFinder) ByteBuffer(java.nio.ByteBuffer) BtreeBuilder(org.apache.carbondata.core.datastore.BtreeBuilder) Test(org.junit.Test)

Example 7 with BTreeBuilderInfo

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

the class BlockIndexTest method testBuild.

@Test
public void testBuild() {
    segmentInfo = new SegmentInfo();
    new MockUp<BlockletBTreeBuilder>() {

        @Mock
        public void build(BTreeBuilderInfo segmentBuilderInfos) {
        }
    };
    int expectedValue = 0;
    BlockIndex blockIndex = new BlockIndex();
    columnSchema.setColumnName("employeeName");
    columnSchemaList.add(new ColumnSchema());
    footer.setSegmentInfo(segmentInfo);
    footer.setColumnInTable(columnSchemaList);
    footer.setBlockletList(Arrays.asList(blockletInfo));
    footerList.add(footer);
    blockIndex.buildIndex(footerList);
    assertEquals(footerList.get(0).getNumberOfRows(), expectedValue);
}
Also used : BTreeBuilderInfo(org.apache.carbondata.core.datastore.BTreeBuilderInfo) SegmentInfo(org.apache.carbondata.core.metadata.blocklet.SegmentInfo) MockUp(mockit.MockUp) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) Test(org.junit.Test)

Example 8 with BTreeBuilderInfo

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

the class SegmentTaskIndex method buildIndex.

/**
   * Below method is store the blocks in some data structure
   *
   */
public void buildIndex(List<DataFileFooter> footerList) {
    // create a segment builder info
    // in case of segment create we do not need any file path and each column value size
    // as Btree will be build as per min max and start key
    BTreeBuilderInfo btreeBuilderInfo = new BTreeBuilderInfo(footerList, null);
    BtreeBuilder blocksBuilder = new BlockBTreeBuilder();
    // load the metadata
    blocksBuilder.build(btreeBuilderInfo);
    dataRefNode = blocksBuilder.get();
    for (DataFileFooter footer : footerList) {
        totalNumberOfRows += footer.getNumberOfRows();
    }
}
Also used : DataFileFooter(org.apache.carbondata.core.metadata.blocklet.DataFileFooter) BTreeBuilderInfo(org.apache.carbondata.core.datastore.BTreeBuilderInfo) BlockBTreeBuilder(org.apache.carbondata.core.datastore.impl.btree.BlockBTreeBuilder) BtreeBuilder(org.apache.carbondata.core.datastore.BtreeBuilder)

Example 9 with BTreeBuilderInfo

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

the class BlockIndex method buildIndex.

/**
   * Below method will be used to load the data block
   *
   */
public void buildIndex(List<DataFileFooter> footerList) {
    // create a metadata details
    // this will be useful in query handling
    segmentProperties = new SegmentProperties(footerList.get(0).getColumnInTable(), footerList.get(0).getSegmentInfo().getColumnCardinality());
    // create a segment builder info
    BTreeBuilderInfo indexBuilderInfo = new BTreeBuilderInfo(footerList, segmentProperties.getDimensionColumnsValueSize());
    BtreeBuilder blocksBuilder = new BlockletBTreeBuilder();
    // load the metadata
    blocksBuilder.build(indexBuilderInfo);
    dataRefNode = blocksBuilder.get();
    totalNumberOfRows = footerList.get(0).getNumberOfRows();
}
Also used : BTreeBuilderInfo(org.apache.carbondata.core.datastore.BTreeBuilderInfo) BlockletBTreeBuilder(org.apache.carbondata.core.datastore.impl.btree.BlockletBTreeBuilder) BtreeBuilder(org.apache.carbondata.core.datastore.BtreeBuilder)

Example 10 with BTreeBuilderInfo

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

the class SegmentTaskIndexTest method testBuild.

@Test
public void testBuild() {
    new MockUp<BlockBTreeBuilder>() {

        @Mock
        public void build(BTreeBuilderInfo segmentBuilderInfos) {
        }
    };
    long numberOfRows = 100;
    columnSchema.setColumnName("employeeName");
    columnSchemaList.add(new ColumnSchema());
    footer.setSegmentInfo(segmentInfo);
    footer.setColumnInTable(columnSchemaList);
    footer.setBlockletList(Arrays.asList(blockletInfo));
    footer.setNumberOfRows(numberOfRows);
    footerList.add(footer);
    SegmentProperties properties = new SegmentProperties(footerList.get(0).getColumnInTable(), footerList.get(0).getSegmentInfo().getColumnCardinality());
    SegmentTaskIndex segmentTaskIndex = new SegmentTaskIndex(properties);
    segmentTaskIndex.buildIndex(footerList);
    assertEquals(footerList.get(0).getNumberOfRows(), numberOfRows);
}
Also used : BTreeBuilderInfo(org.apache.carbondata.core.datastore.BTreeBuilderInfo) MockUp(mockit.MockUp) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) Test(org.junit.Test)

Aggregations

BTreeBuilderInfo (org.apache.carbondata.core.datastore.BTreeBuilderInfo)11 BtreeBuilder (org.apache.carbondata.core.datastore.BtreeBuilder)9 Test (org.junit.Test)9 DataFileFooter (org.apache.carbondata.core.metadata.blocklet.DataFileFooter)8 DataRefNode (org.apache.carbondata.core.datastore.DataRefNode)6 DataRefNodeFinder (org.apache.carbondata.core.datastore.DataRefNodeFinder)5 IndexKey (org.apache.carbondata.core.datastore.IndexKey)5 KeyGenerator (org.apache.carbondata.core.keygenerator.KeyGenerator)3 MultiDimKeyVarLengthGenerator (org.apache.carbondata.core.keygenerator.mdkey.MultiDimKeyVarLengthGenerator)3 ByteBuffer (java.nio.ByteBuffer)2 MockUp (mockit.MockUp)2 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)2 BlockBTreeBuilder (org.apache.carbondata.core.datastore.impl.btree.BlockBTreeBuilder)1 BlockletBTreeBuilder (org.apache.carbondata.core.datastore.impl.btree.BlockletBTreeBuilder)1 SegmentInfo (org.apache.carbondata.core.metadata.blocklet.SegmentInfo)1