Search in sources :

Example 6 with Compressor

use of org.apache.carbondata.core.datastore.compression.Compressor in project carbondata by apache.

the class ColumnPage method decompressDecimalPage.

/**
 * Decompress data and create a decimal column page using the decompressed data
 */
public static ColumnPage decompressDecimalPage(ColumnPageEncoderMeta meta, byte[] compressedData, int offset, int length) throws MemoryException {
    Compressor compressor = CompressorFactory.getInstance().getCompressor(meta.getCompressorName());
    TableSpec.ColumnSpec columnSpec = meta.getColumnSpec();
    ColumnPage decimalPage = null;
    DataType storeDataType = meta.getStoreDataType();
    if (storeDataType == DataTypes.BYTE) {
        byte[] byteData = compressor.unCompressByte(compressedData, offset, length);
        decimalPage = createDecimalPage(columnSpec, meta.getStoreDataType(), byteData.length);
        decimalPage.setBytePage(byteData);
        return decimalPage;
    } else if (storeDataType == DataTypes.SHORT) {
        short[] shortData = compressor.unCompressShort(compressedData, offset, length);
        decimalPage = createDecimalPage(columnSpec, meta.getStoreDataType(), shortData.length);
        decimalPage.setShortPage(shortData);
        return decimalPage;
    } else if (storeDataType == DataTypes.SHORT_INT) {
        byte[] shortIntData = compressor.unCompressByte(compressedData, offset, length);
        decimalPage = createDecimalPage(columnSpec, meta.getStoreDataType(), shortIntData.length);
        decimalPage.setShortIntPage(shortIntData);
        return decimalPage;
    } else if (storeDataType == DataTypes.INT) {
        int[] intData = compressor.unCompressInt(compressedData, offset, length);
        decimalPage = createDecimalPage(columnSpec, meta.getStoreDataType(), intData.length);
        decimalPage.setIntPage(intData);
        return decimalPage;
    } else if (storeDataType == DataTypes.LONG) {
        long[] longData = compressor.unCompressLong(compressedData, offset, length);
        decimalPage = createDecimalPage(columnSpec, meta.getStoreDataType(), longData.length);
        decimalPage.setLongPage(longData);
        return decimalPage;
    } else {
        byte[] lvEncodedBytes = compressor.unCompressByte(compressedData, offset, length);
        return newDecimalPage(columnSpec, lvEncodedBytes);
    }
}
Also used : TableSpec(org.apache.carbondata.core.datastore.TableSpec) Compressor(org.apache.carbondata.core.datastore.compression.Compressor) DataType(org.apache.carbondata.core.metadata.datatype.DataType)

Aggregations

Compressor (org.apache.carbondata.core.datastore.compression.Compressor)6 ArrayList (java.util.ArrayList)3 ColumnPage (org.apache.carbondata.core.datastore.page.ColumnPage)3 LazyColumnPage (org.apache.carbondata.core.datastore.page.LazyColumnPage)3 ColumnPageEncoder (org.apache.carbondata.core.datastore.page.encoding.ColumnPageEncoder)3 ColumnPageEncoderMeta (org.apache.carbondata.core.datastore.page.encoding.ColumnPageEncoderMeta)3 Encoding (org.apache.carbondata.format.Encoding)3 TableSpec (org.apache.carbondata.core.datastore.TableSpec)2 DataType (org.apache.carbondata.core.metadata.datatype.DataType)2 PresenceMeta (org.apache.carbondata.format.PresenceMeta)1