use of org.apache.carbondata.format.FileHeader in project carbondata by apache.
the class CarbonMetadataUtil method getFileHeader.
/**
* Below method will be used to prepare the file header object for carbondata file
*
* @param isFooterPresent is footer present in carbon data file
* @param columnSchemaList list of column schema
* @param schemaUpdatedTimeStamp schema updated time stamp to be used for restructure scenarios
* @return file header thrift object
*/
public static FileHeader getFileHeader(boolean isFooterPresent, List<ColumnSchema> columnSchemaList, long schemaUpdatedTimeStamp) {
FileHeader fileHeader = new FileHeader();
ColumnarFormatVersion version = CarbonProperties.getInstance().getFormatVersion();
fileHeader.setIs_footer_present(isFooterPresent);
fileHeader.setColumn_schema(columnSchemaList);
fileHeader.setVersion(version.number());
fileHeader.setTime_stamp(schemaUpdatedTimeStamp);
return fileHeader;
}
use of org.apache.carbondata.format.FileHeader in project carbondata by apache.
the class DataFileFooterConverterV3 method readDataFileFooter.
/**
* Below method will be used to convert thrift file meta to wrapper file meta
* This method will read the footer from footer offset present in the data file
* 1. It will read the header from carbon data file, header starts from 0 offset
* 2. It will set the stream offset
* 3. It will read the footer data from file
* 4. parse the footer to thrift object
* 5. convert to wrapper object
*
* @param tableBlockInfo
* table block info
* @return data file footer
*/
@Override
public DataFileFooter readDataFileFooter(TableBlockInfo tableBlockInfo) throws IOException {
DataFileFooter dataFileFooter = new DataFileFooter();
CarbonHeaderReader carbonHeaderReader = new CarbonHeaderReader(tableBlockInfo.getFilePath());
FileHeader fileHeader = carbonHeaderReader.readHeader();
CarbonFooterReaderV3 reader = new CarbonFooterReaderV3(tableBlockInfo.getFilePath(), tableBlockInfo.getBlockOffset());
FileFooter3 footer = reader.readFooterVersion3();
dataFileFooter.setVersionId(ColumnarFormatVersion.valueOf((short) fileHeader.getVersion()));
dataFileFooter.setNumberOfRows(footer.getNum_rows());
dataFileFooter.setSegmentInfo(getSegmentInfo(footer.getSegment_info()));
dataFileFooter.setSchemaUpdatedTimeStamp(fileHeader.getTime_stamp());
List<ColumnSchema> columnSchemaList = new ArrayList<ColumnSchema>();
List<org.apache.carbondata.format.ColumnSchema> table_columns = fileHeader.getColumn_schema();
for (int i = 0; i < table_columns.size(); i++) {
columnSchemaList.add(thriftColumnSchmeaToWrapperColumnSchema(table_columns.get(i)));
}
dataFileFooter.setColumnInTable(columnSchemaList);
List<org.apache.carbondata.format.BlockletIndex> leaf_node_indices_Thrift = footer.getBlocklet_index_list();
List<BlockletIndex> blockletIndexList = new ArrayList<BlockletIndex>();
for (int i = 0; i < leaf_node_indices_Thrift.size(); i++) {
BlockletIndex blockletIndex = getBlockletIndex(leaf_node_indices_Thrift.get(i));
blockletIndexList.add(blockletIndex);
}
List<org.apache.carbondata.format.BlockletInfo3> leaf_node_infos_Thrift = footer.getBlocklet_info_list3();
List<BlockletInfo> blockletInfoList = new ArrayList<BlockletInfo>();
for (int i = 0; i < leaf_node_infos_Thrift.size(); i++) {
BlockletInfo blockletInfo = getBlockletInfo(leaf_node_infos_Thrift.get(i), getNumberOfDimensionColumns(columnSchemaList));
blockletInfo.setBlockletIndex(blockletIndexList.get(i));
blockletInfoList.add(blockletInfo);
}
dataFileFooter.setBlockletList(blockletInfoList);
dataFileFooter.setBlockletIndex(getBlockletIndexForDataFileFooter(blockletIndexList));
return dataFileFooter;
}
use of org.apache.carbondata.format.FileHeader in project carbondata by apache.
the class CarbonHeaderReader method readHeader.
/**
* It reads the metadata in FileFooter thrift object format.
*
* @return
* @throws IOException
*/
public FileHeader readHeader() throws IOException {
ThriftReader thriftReader = openThriftReader(filePath);
thriftReader.open();
FileHeader header = (FileHeader) thriftReader.read();
thriftReader.close();
return header;
}
Aggregations