use of org.apache.carbondata.format.FileFooter3 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);
}
Aggregations