Search in sources :

Example 6 with CarbonFooterReader

use of org.apache.carbondata.core.reader.CarbonFooterReader in project carbondata by apache.

the class DataFileFooterConverter method getSchema.

@Override
public List<ColumnSchema> getSchema(TableBlockInfo tableBlockInfo) throws IOException {
    FileReader fileReader = null;
    List<ColumnSchema> columnSchemaList = new ArrayList<ColumnSchema>();
    try {
        long completeBlockLength = tableBlockInfo.getBlockLength();
        long footerPointer = completeBlockLength - 8;
        fileReader = FileFactory.getFileHolder(FileFactory.getFileType(tableBlockInfo.getFilePath()));
        long actualFooterOffset = fileReader.readLong(tableBlockInfo.getFilePath(), footerPointer);
        CarbonFooterReader reader = new CarbonFooterReader(tableBlockInfo.getFilePath(), actualFooterOffset);
        FileFooter footer = reader.readFooter();
        List<org.apache.carbondata.format.ColumnSchema> table_columns = footer.getTable_columns();
        for (int i = 0; i < table_columns.size(); i++) {
            columnSchemaList.add(thriftColumnSchmeaToWrapperColumnSchema(table_columns.get(i)));
        }
    } finally {
        if (null != fileReader) {
            fileReader.finish();
        }
    }
    return columnSchemaList;
}
Also used : ArrayList(java.util.ArrayList) DataFileFooter(org.apache.carbondata.core.metadata.blocklet.DataFileFooter) FileFooter(org.apache.carbondata.format.FileFooter) FileReader(org.apache.carbondata.core.datastore.FileReader) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) CarbonFooterReader(org.apache.carbondata.core.reader.CarbonFooterReader)

Aggregations

CarbonFooterReader (org.apache.carbondata.core.reader.CarbonFooterReader)6 ArrayList (java.util.ArrayList)3 DataFileFooter (org.apache.carbondata.core.metadata.blocklet.DataFileFooter)3 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)3 FileFooter (org.apache.carbondata.format.FileFooter)3 FileReader (org.apache.carbondata.core.datastore.FileReader)2 SegmentProperties (org.apache.carbondata.core.datastore.block.SegmentProperties)2 BlockletInfoColumnar (org.apache.carbondata.core.metadata.BlockletInfoColumnar)2 BlockletInfo (org.apache.carbondata.core.metadata.blocklet.BlockletInfo)2 BlockletIndex (org.apache.carbondata.core.metadata.blocklet.index.BlockletIndex)2 ColumnSchema (org.apache.carbondata.format.ColumnSchema)2 Test (org.junit.Test)2 CarbonTableIdentifier (org.apache.carbondata.core.carbon.CarbonTableIdentifier)1 FileHolder (org.apache.carbondata.core.datastorage.store.FileHolder)1 CarbonFile (org.apache.carbondata.core.datastore.filesystem.CarbonFile)1 CarbonFileFilter (org.apache.carbondata.core.datastore.filesystem.CarbonFileFilter)1 Before (org.junit.Before)1