Search in sources :

Example 1 with ValueEncoderMeta

use of org.apache.carbondata.core.metadata.ValueEncoderMeta in project carbondata by apache.

the class CarbonUtil method getValueCompressionModel.

/**
   * Below method will be used to get the value compression model of the
   * measure data chunk
   *
   * @return value compression model
   */
public static WriterCompressModel getValueCompressionModel(List<ValueEncoderMeta> encodeMetaList) {
    Object[] maxValue = new Object[encodeMetaList.size()];
    Object[] minValue = new Object[encodeMetaList.size()];
    Object[] uniqueValue = new Object[encodeMetaList.size()];
    int[] decimal = new int[encodeMetaList.size()];
    DataType[] type = new DataType[encodeMetaList.size()];
    byte[] dataTypeSelected = new byte[encodeMetaList.size()];
    /*
     * to fill the meta data required for value compression model
     */
    for (int i = 0; i < dataTypeSelected.length; i++) {
        // always 1
        ValueEncoderMeta valueEncoderMeta = encodeMetaList.get(i);
        maxValue[i] = valueEncoderMeta.getMaxValue();
        minValue[i] = valueEncoderMeta.getMinValue();
        uniqueValue[i] = valueEncoderMeta.getUniqueValue();
        decimal[i] = valueEncoderMeta.getDecimal();
        type[i] = valueEncoderMeta.getType();
        dataTypeSelected[i] = valueEncoderMeta.getDataTypeSelected();
    }
    MeasureMetaDataModel measureMetadataModel = new MeasureMetaDataModel(minValue, maxValue, decimal, dataTypeSelected.length, uniqueValue, type, dataTypeSelected);
    return ValueCompressionUtil.getWriterCompressModel(measureMetadataModel);
}
Also used : MeasureMetaDataModel(org.apache.carbondata.core.datastore.compression.MeasureMetaDataModel) DataType(org.apache.carbondata.core.metadata.datatype.DataType) ValueEncoderMeta(org.apache.carbondata.core.metadata.ValueEncoderMeta)

Example 2 with ValueEncoderMeta

use of org.apache.carbondata.core.metadata.ValueEncoderMeta in project carbondata by apache.

the class CarbonMetadataUtil method deserializeValueEncoderMeta.

private static ValueEncoderMeta deserializeValueEncoderMeta(ByteBuffer byteBuffer) throws IOException {
    ByteArrayInputStream bis = new ByteArrayInputStream(byteBuffer.array());
    ObjectInputStream objStream = new ObjectInputStream(bis);
    ValueEncoderMeta encoderMeta = null;
    try {
        encoderMeta = (ValueEncoderMeta) objStream.readObject();
    } catch (ClassNotFoundException e) {
        LOGGER.error("Error while reading ValueEncoderMeta");
    }
    return encoderMeta;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ValueEncoderMeta(org.apache.carbondata.core.metadata.ValueEncoderMeta) ObjectInputStream(java.io.ObjectInputStream)

Example 3 with ValueEncoderMeta

use of org.apache.carbondata.core.metadata.ValueEncoderMeta in project carbondata by apache.

the class CarbonUtil method deserializeEncoderMetaNew.

public static ValueEncoderMeta deserializeEncoderMetaNew(byte[] encodeMeta) {
    ByteBuffer buffer = ByteBuffer.wrap(encodeMeta);
    char measureType = buffer.getChar();
    ValueEncoderMeta valueEncoderMeta = new ValueEncoderMeta();
    valueEncoderMeta.setType(measureType);
    switch(measureType) {
        case CarbonCommonConstants.DOUBLE_MEASURE:
            valueEncoderMeta.setMaxValue(buffer.getDouble());
            valueEncoderMeta.setMinValue(buffer.getDouble());
            valueEncoderMeta.setUniqueValue(buffer.getDouble());
            break;
        case CarbonCommonConstants.BIG_DECIMAL_MEASURE:
            valueEncoderMeta.setMaxValue(0.0);
            valueEncoderMeta.setMinValue(0.0);
            valueEncoderMeta.setUniqueValue(0.0);
            break;
        case CarbonCommonConstants.BIG_INT_MEASURE:
            valueEncoderMeta.setMaxValue(buffer.getLong());
            valueEncoderMeta.setMinValue(buffer.getLong());
            valueEncoderMeta.setUniqueValue(buffer.getLong());
            break;
        default:
            throw new IllegalArgumentException("invalid measure type");
    }
    valueEncoderMeta.setDecimal(buffer.getInt());
    valueEncoderMeta.setDataTypeSelected(buffer.get());
    return valueEncoderMeta;
}
Also used : ValueEncoderMeta(org.apache.carbondata.core.metadata.ValueEncoderMeta) ByteBuffer(java.nio.ByteBuffer)

Example 4 with ValueEncoderMeta

use of org.apache.carbondata.core.metadata.ValueEncoderMeta in project carbondata by apache.

the class CarbonMetadataUtil method createValueEncoderMeta.

private static ValueEncoderMeta createValueEncoderMeta(WriterCompressModel compressionModel, int index) {
    ValueEncoderMeta encoderMeta = new ValueEncoderMeta();
    encoderMeta.setMaxValue(compressionModel.getMaxValue()[index]);
    encoderMeta.setMinValue(compressionModel.getMinValue()[index]);
    encoderMeta.setDataTypeSelected(compressionModel.getDataTypeSelected()[index]);
    encoderMeta.setDecimal(compressionModel.getMantissa()[index]);
    encoderMeta.setType(compressionModel.getType()[index]);
    encoderMeta.setUniqueValue(compressionModel.getUniqueValue()[index]);
    return encoderMeta;
}
Also used : ValueEncoderMeta(org.apache.carbondata.core.metadata.ValueEncoderMeta)

Example 5 with ValueEncoderMeta

use of org.apache.carbondata.core.metadata.ValueEncoderMeta in project carbondata by apache.

the class CompressedMeasureChunkFileBasedReaderV2 method convertToMeasureChunk.

public MeasureColumnDataChunk convertToMeasureChunk(MeasureRawColumnChunk measureRawColumnChunk, int pageNumber) throws IOException {
    MeasureColumnDataChunk datChunk = new MeasureColumnDataChunk();
    DataChunk2 measureColumnChunk = null;
    int copyPoint = measureRawColumnChunk.getOffSet();
    int blockIndex = measureRawColumnChunk.getBlockletId();
    ByteBuffer rawData = measureRawColumnChunk.getRawData();
    if (measureColumnChunkOffsets.size() - 1 == blockIndex) {
        measureColumnChunk = CarbonUtil.readDataChunk(rawData, copyPoint, measureColumnChunkLength.get(blockIndex));
        synchronized (measureRawColumnChunk.getFileReader()) {
            rawData = measureRawColumnChunk.getFileReader().readByteBuffer(filePath, measureColumnChunkOffsets.get(blockIndex) + measureColumnChunkLength.get(blockIndex), measureColumnChunk.data_page_length);
        }
    } else {
        measureColumnChunk = CarbonUtil.readDataChunk(rawData, copyPoint, measureColumnChunkLength.get(blockIndex));
        copyPoint += measureColumnChunkLength.get(blockIndex);
    }
    List<ValueEncoderMeta> valueEncodeMeta = new ArrayList<>();
    for (int i = 0; i < measureColumnChunk.getEncoder_meta().size(); i++) {
        valueEncodeMeta.add(CarbonUtil.deserializeEncoderMeta(measureColumnChunk.getEncoder_meta().get(i).array()));
    }
    WriterCompressModel compressionModel = CarbonUtil.getValueCompressionModel(valueEncodeMeta);
    ValueCompressionHolder values = compressionModel.getValueCompressionHolder()[0];
    // uncompress
    values.uncompress(compressionModel.getConvertedDataType()[0], rawData.array(), copyPoint, measureColumnChunk.data_page_length, compressionModel.getMantissa()[0], compressionModel.getMaxValue()[0], numberOfRows);
    CarbonReadDataHolder measureDataHolder = new CarbonReadDataHolder(values);
    // set the data chunk
    datChunk.setMeasureDataHolder(measureDataHolder);
    // set the enun value indexes
    datChunk.setNullValueIndexHolder(getPresenceMeta(measureColumnChunk.presence));
    return datChunk;
}
Also used : WriterCompressModel(org.apache.carbondata.core.datastore.compression.WriterCompressModel) ValueCompressionHolder(org.apache.carbondata.core.datastore.compression.ValueCompressionHolder) DataChunk2(org.apache.carbondata.format.DataChunk2) ArrayList(java.util.ArrayList) CarbonReadDataHolder(org.apache.carbondata.core.datastore.dataholder.CarbonReadDataHolder) ValueEncoderMeta(org.apache.carbondata.core.metadata.ValueEncoderMeta) MeasureColumnDataChunk(org.apache.carbondata.core.datastore.chunk.MeasureColumnDataChunk) ByteBuffer(java.nio.ByteBuffer)

Aggregations

ValueEncoderMeta (org.apache.carbondata.core.metadata.ValueEncoderMeta)17 ByteBuffer (java.nio.ByteBuffer)8 ArrayList (java.util.ArrayList)6 DataChunk (org.apache.carbondata.core.metadata.blocklet.datachunk.DataChunk)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 MeasureColumnDataChunk (org.apache.carbondata.core.datastore.chunk.MeasureColumnDataChunk)3 ValueCompressionHolder (org.apache.carbondata.core.datastore.compression.ValueCompressionHolder)3 CarbonReadDataHolder (org.apache.carbondata.core.datastore.dataholder.CarbonReadDataHolder)3 ObjectInputStream (java.io.ObjectInputStream)2 WriterCompressModel (org.apache.carbondata.core.datastore.compression.WriterCompressModel)2 ColumnPageDecoder (org.apache.carbondata.core.datastore.page.encoding.ColumnPageDecoder)2 Encoding (org.apache.carbondata.core.metadata.encoder.Encoding)2 BlockletInfo (org.apache.carbondata.format.BlockletInfo)2 DataChunk (org.apache.carbondata.format.DataChunk)2 DataChunk2 (org.apache.carbondata.format.DataChunk2)2 Encoding (org.apache.carbondata.format.Encoding)2 DataInputStream (java.io.DataInputStream)1 IOException (java.io.IOException)1 MeasureMetaDataModel (org.apache.carbondata.core.datastore.compression.MeasureMetaDataModel)1 ReaderCompressModel (org.apache.carbondata.core.datastore.compression.ReaderCompressModel)1