Search in sources :

Example 1 with Bits

use of org.apache.carbondata.core.keygenerator.mdkey.Bits in project carbondata by apache.

the class PrimitiveQueryType method getDataBasedOnDataTypeFromSurrogates.

@Override
public Object getDataBasedOnDataTypeFromSurrogates(ByteBuffer surrogateData) {
    byte[] data = new byte[keySize];
    surrogateData.get(data);
    Bits bit = new Bits(new int[] { keySize * 8 });
    int surrgateValue = (int) bit.getKeyArray(data, 0)[0];
    Object actualData = null;
    if (isDirectDictionary) {
        DirectDictionaryGenerator directDictionaryGenerator = DirectDictionaryKeyGeneratorFactory.getDirectDictionaryGenerator(dataType);
        actualData = directDictionaryGenerator.getValueFromSurrogate(surrgateValue);
    } else {
        String dictionaryValueForKey = dictionary.getDictionaryValueForKey(surrgateValue);
        actualData = DataTypeUtil.getDataBasedOnDataType(dictionaryValueForKey, this.dataType);
    }
    return actualData;
}
Also used : Bits(org.apache.carbondata.core.keygenerator.mdkey.Bits) DirectDictionaryGenerator(org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryGenerator)

Example 2 with Bits

use of org.apache.carbondata.core.keygenerator.mdkey.Bits in project carbondata by apache.

the class PrimitiveQueryTypeTest method getDataBasedOnDataTypeFromSurrogates.

public Object getDataBasedOnDataTypeFromSurrogates(ByteBuffer surrogateData) {
    int keySize = 2;
    byte[] data = new byte[keySize];
    surrogateData.get(data);
    Bits bit = new Bits(new int[] { keySize * 8 });
    int surrgateValue = (int) bit.getKeyArray(data, 0)[0];
    Object actualData = null;
    if (isDirectDictionary) {
        DirectDictionaryGenerator directDictionaryGenerator = DirectDictionaryKeyGeneratorFactory.getDirectDictionaryGenerator(DataTypes.TIMESTAMP);
        actualData = directDictionaryGenerator.getValueFromSurrogate(surrgateValue);
    } else {
        String dictionaryValueForKey = dictionary.getDictionaryValueForKey(surrgateValue);
        actualData = DataTypeUtil.getDataBasedOnDataType(dictionaryValueForKey, DataTypes.TIMESTAMP);
    }
    return actualData;
}
Also used : Bits(org.apache.carbondata.core.keygenerator.mdkey.Bits) DirectDictionaryGenerator(org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryGenerator)

Aggregations

DirectDictionaryGenerator (org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryGenerator)2 Bits (org.apache.carbondata.core.keygenerator.mdkey.Bits)2