use of org.apache.carbondata.core.keygenerator.KeyGenerator in project carbondata by apache.
the class FilterUtil method getKeyArray.
/**
* Below method will be used to covert the filter surrogate keys
* to mdkey
*
* @param dimColumnFilterInfo
* @param carbonDimension
* @param segmentProperties
* @return
*/
public static byte[][] getKeyArray(DimColumnFilterInfo dimColumnFilterInfo, CarbonDimension carbonDimension, SegmentProperties segmentProperties) {
if (!carbonDimension.hasEncoding(Encoding.DICTIONARY)) {
return dimColumnFilterInfo.getNoDictionaryFilterValuesList().toArray((new byte[dimColumnFilterInfo.getNoDictionaryFilterValuesList().size()][]));
}
KeyGenerator blockLevelKeyGenerator = segmentProperties.getDimensionKeyGenerator();
int[] dimColumnsCardinality = segmentProperties.getDimColumnsCardinality();
int[] keys = new int[blockLevelKeyGenerator.getDimCount()];
List<byte[]> filterValuesList = new ArrayList<byte[]>(20);
Arrays.fill(keys, 0);
int keyOrdinalOfDimensionFromCurrentBlock = carbonDimension.getKeyOrdinal();
if (null != dimColumnFilterInfo) {
int[] rangesForMaskedByte = getRangesForMaskedByte(keyOrdinalOfDimensionFromCurrentBlock, blockLevelKeyGenerator);
for (Integer surrogate : dimColumnFilterInfo.getFilterList()) {
try {
if (surrogate <= dimColumnsCardinality[keyOrdinalOfDimensionFromCurrentBlock]) {
keys[keyOrdinalOfDimensionFromCurrentBlock] = surrogate;
filterValuesList.add(getMaskedKey(rangesForMaskedByte, blockLevelKeyGenerator.generateKey(keys)));
} else {
break;
}
} catch (KeyGenException e) {
LOGGER.error(e.getMessage());
}
}
}
return filterValuesList.toArray(new byte[filterValuesList.size()][]);
}
Aggregations