Search in sources :

Example 1 with TablePageKey

use of org.apache.carbondata.core.datastore.page.key.TablePageKey in project carbondata by apache.

the class CarbonMetadataUtilTest method testConvertFileFooter.

@Test
public void testConvertFileFooter() throws Exception {
    int[] cardinality = { 1, 2, 3, 4, 5 };
    org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema colSchema = new org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema();
    org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema colSchema1 = new org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema();
    List<org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema> columnSchemaList = new ArrayList<>();
    columnSchemaList.add(colSchema);
    columnSchemaList.add(colSchema1);
    SegmentProperties segmentProperties = new SegmentProperties(columnSchemaList, cardinality);
    final EncodedColumnPage measure = new EncodedColumnPage(new DataChunk2(), new byte[] { 0, 1 }, PrimitivePageStatsCollector.newInstance(org.apache.carbondata.core.metadata.datatype.DataTypes.BYTE));
    new MockUp<EncodedTablePage>() {

        @SuppressWarnings("unused")
        @Mock
        public EncodedColumnPage getMeasure(int measureIndex) {
            return measure;
        }
    };
    new MockUp<TablePageKey>() {

        @SuppressWarnings("unused")
        @Mock
        public byte[] serializeStartKey() {
            return new byte[] { 1, 2 };
        }

        @SuppressWarnings("unused")
        @Mock
        public byte[] serializeEndKey() {
            return new byte[] { 1, 2 };
        }
    };
    TablePageKey key = new TablePageKey(3, segmentProperties, false);
    EncodedTablePage encodedTablePage = EncodedTablePage.newInstance(3, new EncodedColumnPage[0], new EncodedColumnPage[0], key);
    List<EncodedTablePage> encodedTablePageList = new ArrayList<>();
    encodedTablePageList.add(encodedTablePage);
    BlockletInfo3 blockletInfoColumnar1 = new BlockletInfo3();
    List<BlockletInfo3> blockletInfoColumnarList = new ArrayList<>();
    blockletInfoColumnarList.add(blockletInfoColumnar1);
    byte[] byteMaxArr = "1".getBytes();
    byte[] byteMinArr = "2".getBytes();
    BlockletIndex index = getBlockletIndex(encodedTablePageList, segmentProperties.getMeasures());
    List<BlockletIndex> indexList = new ArrayList<>();
    indexList.add(index);
    BlockletMinMaxIndex blockletMinMaxIndex = new BlockletMinMaxIndex();
    blockletMinMaxIndex.addToMax_values(ByteBuffer.wrap(byteMaxArr));
    blockletMinMaxIndex.addToMin_values(ByteBuffer.wrap(byteMinArr));
    FileFooter3 footer = convertFileFooterVersion3(blockletInfoColumnarList, indexList, cardinality, 2);
    assertEquals(footer.getBlocklet_index_list(), indexList);
}
Also used : BlockletIndex(org.apache.carbondata.format.BlockletIndex) CarbonMetadataUtil.getBlockletIndex(org.apache.carbondata.core.util.CarbonMetadataUtil.getBlockletIndex) ArrayList(java.util.ArrayList) EncodedTablePage(org.apache.carbondata.core.datastore.page.EncodedTablePage) ColumnSchema(org.apache.carbondata.format.ColumnSchema) MockUp(mockit.MockUp) TablePageKey(org.apache.carbondata.core.datastore.page.key.TablePageKey) BlockletMinMaxIndex(org.apache.carbondata.format.BlockletMinMaxIndex) FileFooter3(org.apache.carbondata.format.FileFooter3) EncodedColumnPage(org.apache.carbondata.core.datastore.page.encoding.EncodedColumnPage) BlockletInfo3(org.apache.carbondata.format.BlockletInfo3) DataChunk2(org.apache.carbondata.format.DataChunk2) SegmentProperties(org.apache.carbondata.core.datastore.block.SegmentProperties) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 MockUp (mockit.MockUp)1 SegmentProperties (org.apache.carbondata.core.datastore.block.SegmentProperties)1 EncodedTablePage (org.apache.carbondata.core.datastore.page.EncodedTablePage)1 EncodedColumnPage (org.apache.carbondata.core.datastore.page.encoding.EncodedColumnPage)1 TablePageKey (org.apache.carbondata.core.datastore.page.key.TablePageKey)1 CarbonMetadataUtil.getBlockletIndex (org.apache.carbondata.core.util.CarbonMetadataUtil.getBlockletIndex)1 BlockletIndex (org.apache.carbondata.format.BlockletIndex)1 BlockletInfo3 (org.apache.carbondata.format.BlockletInfo3)1 BlockletMinMaxIndex (org.apache.carbondata.format.BlockletMinMaxIndex)1 ColumnSchema (org.apache.carbondata.format.ColumnSchema)1 DataChunk2 (org.apache.carbondata.format.DataChunk2)1 FileFooter3 (org.apache.carbondata.format.FileFooter3)1 Test (org.junit.Test)1