Search in sources :

Example 1 with MeasureMetaDataModel

use of org.apache.carbondata.core.datastore.compression.MeasureMetaDataModel 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 MeasureMetaDataModel

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

the class ValueCompressionUtilTest method testToGetValueCompressionModelForByteAndInt.

@Test
public void testToGetValueCompressionModelForByteAndInt() {
    Object[] maxValues = { -32766.00 };
    Object[] minValues = { 32744.0 };
    int[] decimalLength = { 0 };
    Object[] uniqueValues = { 5 };
    DataType[] types = { DataType.DOUBLE };
    byte[] dataTypeSelected = { 1 };
    MeasureMetaDataModel measureMetaDataModel = new MeasureMetaDataModel(maxValues, minValues, decimalLength, 1, uniqueValues, types, dataTypeSelected);
    WriterCompressModel writerCompressModel = ValueCompressionUtil.getWriterCompressModel(measureMetaDataModel);
    assertEquals(ValueCompressionUtil.COMPRESSION_TYPE.ADAPTIVE, writerCompressModel.getCompType(0));
}
Also used : WriterCompressModel(org.apache.carbondata.core.datastore.compression.WriterCompressModel) MeasureMetaDataModel(org.apache.carbondata.core.datastore.compression.MeasureMetaDataModel) DataType(org.apache.carbondata.core.metadata.datatype.DataType) Test(org.junit.Test)

Example 3 with MeasureMetaDataModel

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

the class ValueCompressionUtilTest method testToGetValueCompressionModel.

@Test
public void testToGetValueCompressionModel() {
    Object[] maxValues = { 10L, 20L, 30L };
    Object[] minValues = { 1L, 2L, 3L };
    int[] decimalLength = { 0, 0, 0 };
    Object[] uniqueValues = { 5, new Long[] { 2L, 4L }, 2L };
    DataType[] types = { DataType.LONG, DataType.LONG, DataType.LONG };
    byte[] dataTypeSelected = { 1, 2, 4 };
    MeasureMetaDataModel measureMetaDataModel = new MeasureMetaDataModel(maxValues, minValues, decimalLength, 3, uniqueValues, types, dataTypeSelected);
    WriterCompressModel writerCompressModel = ValueCompressionUtil.getWriterCompressModel(measureMetaDataModel);
    assertEquals(ValueCompressionUtil.COMPRESSION_TYPE.ADAPTIVE, writerCompressModel.getCompType(0));
    assertEquals(ValueCompressionUtil.COMPRESSION_TYPE.ADAPTIVE, writerCompressModel.getCompType(1));
    assertEquals(ValueCompressionUtil.COMPRESSION_TYPE.ADAPTIVE, writerCompressModel.getCompType(2));
}
Also used : WriterCompressModel(org.apache.carbondata.core.datastore.compression.WriterCompressModel) MeasureMetaDataModel(org.apache.carbondata.core.datastore.compression.MeasureMetaDataModel) DataType(org.apache.carbondata.core.metadata.datatype.DataType) Test(org.junit.Test)

Example 4 with MeasureMetaDataModel

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

the class ValueCompressionUtilTest method testToGetValueCompressionModelForIntAndShort.

@Test
public void testToGetValueCompressionModelForIntAndShort() {
    Object[] maxValues = { 1111111111.0 };
    Object[] minValues = { 1111078433.0 };
    int[] decimalLength = { 0 };
    Object[] uniqueValues = { 5 };
    DataType[] types = { DataType.DOUBLE };
    byte[] dataTypeSelected = { 1 };
    MeasureMetaDataModel measureMetaDataModel = new MeasureMetaDataModel(maxValues, minValues, decimalLength, 1, uniqueValues, types, dataTypeSelected);
    WriterCompressModel writerCompressModel = ValueCompressionUtil.getWriterCompressModel(measureMetaDataModel);
    assertEquals(ValueCompressionUtil.COMPRESSION_TYPE.DELTA_DOUBLE, writerCompressModel.getCompType(0));
}
Also used : WriterCompressModel(org.apache.carbondata.core.datastore.compression.WriterCompressModel) MeasureMetaDataModel(org.apache.carbondata.core.datastore.compression.MeasureMetaDataModel) DataType(org.apache.carbondata.core.metadata.datatype.DataType) Test(org.junit.Test)

Example 5 with MeasureMetaDataModel

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

the class ValueCompressionUtilTest method testToGetValueCompressionModelForByteAndIntAndDataTypeSelected0.

@Test
public void testToGetValueCompressionModelForByteAndIntAndDataTypeSelected0() {
    Object[] maxValues = { -32766.00 };
    Object[] minValues = { 32744.0 };
    int[] decimalLength = { 1 };
    Object[] uniqueValues = { 5 };
    DataType[] types = { DataType.DOUBLE };
    byte[] dataTypeSelected = { 0 };
    MeasureMetaDataModel measureMetaDataModel = new MeasureMetaDataModel(maxValues, minValues, decimalLength, 1, uniqueValues, types, dataTypeSelected);
    WriterCompressModel writerCompressModel = ValueCompressionUtil.getWriterCompressModel(measureMetaDataModel);
    assertEquals(ValueCompressionUtil.COMPRESSION_TYPE.BIGINT, writerCompressModel.getCompType(0));
}
Also used : WriterCompressModel(org.apache.carbondata.core.datastore.compression.WriterCompressModel) MeasureMetaDataModel(org.apache.carbondata.core.datastore.compression.MeasureMetaDataModel) DataType(org.apache.carbondata.core.metadata.datatype.DataType) Test(org.junit.Test)

Aggregations

MeasureMetaDataModel (org.apache.carbondata.core.datastore.compression.MeasureMetaDataModel)9 DataType (org.apache.carbondata.core.metadata.datatype.DataType)9 WriterCompressModel (org.apache.carbondata.core.datastore.compression.WriterCompressModel)8 Test (org.junit.Test)8 ValueEncoderMeta (org.apache.carbondata.core.metadata.ValueEncoderMeta)1