use of org.apache.carbondata.core.keygenerator.KeyGenException in project carbondata by apache.
the class RowLevelFilterExecuterImpl method readSurrogatesFromColumnGroupBlock.
/**
* @param index
* @param dimColumnEvaluatorInfo
* @return read surrogate of given row of given column group dimension
*/
private int readSurrogatesFromColumnGroupBlock(DimensionColumnDataChunk chunk, int index, DimColumnResolvedFilterInfo dimColumnEvaluatorInfo) {
try {
KeyStructureInfo keyStructureInfo = QueryUtil.getKeyStructureInfo(segmentProperties, dimColumnEvaluatorInfo);
byte[] colData = chunk.getChunkData(index);
long[] result = keyStructureInfo.getKeyGenerator().getKeyArray(colData);
int colGroupId = QueryUtil.getColumnGroupId(segmentProperties, dimensionBlocksIndex[0]);
return (int) result[segmentProperties.getColumnGroupMdKeyOrdinal(colGroupId, dimensionBlocksIndex[0])];
} catch (KeyGenException e) {
LOGGER.error(e);
}
return 0;
}
use of org.apache.carbondata.core.keygenerator.KeyGenException 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()][]);
}
use of org.apache.carbondata.core.keygenerator.KeyGenException in project carbondata by apache.
the class DataWriterProcessorStepImpl method processRow.
public void processRow(CarbonRow row, CarbonFactHandler dataHandler) throws KeyGenException {
try {
readCounter++;
dataHandler.addDataToStore(row);
} catch (Exception e) {
throw new CarbonDataLoadingException("unable to generate the mdkey", e);
}
rowCounter.getAndAdd(1);
}
use of org.apache.carbondata.core.keygenerator.KeyGenException in project carbondata by apache.
the class InMemoryBTreeIndex method getDataBlocksOfIndex.
/**
* get data blocks of given btree
*/
private List<DataRefNode> getDataBlocksOfIndex(AbstractIndex abstractIndex) {
List<DataRefNode> blocks = new LinkedList<DataRefNode>();
SegmentProperties segmentProperties = abstractIndex.getSegmentProperties();
try {
IndexKey startIndexKey = FilterUtil.prepareDefaultStartIndexKey(segmentProperties);
IndexKey endIndexKey = FilterUtil.prepareDefaultEndIndexKey(segmentProperties);
// Add all blocks of btree into result
DataRefNodeFinder blockFinder = new BTreeDataRefNodeFinder(segmentProperties.getEachDimColumnValueSize(), segmentProperties.getNumberOfSortColumns(), segmentProperties.getNumberOfNoDictSortColumns());
DataRefNode startBlock = blockFinder.findFirstDataBlock(abstractIndex.getDataRefNode(), startIndexKey);
DataRefNode endBlock = blockFinder.findLastDataBlock(abstractIndex.getDataRefNode(), endIndexKey);
while (startBlock != endBlock) {
blocks.add(startBlock);
startBlock = startBlock.getNextDataRefNode();
}
blocks.add(endBlock);
} catch (KeyGenException e) {
LOG.error("Could not generate start key", e);
}
return blocks;
}
use of org.apache.carbondata.core.keygenerator.KeyGenException in project carbondata by apache.
the class ColumnGroupDimensionDataChunkTest method getKeyStructureInfo.
/**
* Below method will be used to get the key structure info for the query
*
* @param ordinals query model
* @param keyGenerator
* @return key structure info
*/
private KeyStructureInfo getKeyStructureInfo(List<Integer> ordinals, KeyGenerator keyGenerator) {
// getting the masked byte range for dictionary column
int[] maskByteRanges = QueryUtil.getMaskedByteRangeBasedOrdinal(ordinals, keyGenerator);
// getting the masked bytes for query dimension dictionary column
int[] maskedBytes = QueryUtil.getMaskedByte(keyGenerator.getKeySizeInBytes(), maskByteRanges);
// max key for the dictionary dimension present in the query
byte[] maxKey = null;
try {
// getting the max key which will be used to masked and get the
// masked key
maxKey = QueryUtil.getMaxKeyBasedOnOrinal(ordinals, keyGenerator);
} catch (KeyGenException e) {
}
KeyStructureInfo restructureInfos = new KeyStructureInfo();
restructureInfos.setKeyGenerator(keyGenerator);
restructureInfos.setMaskByteRanges(maskByteRanges);
restructureInfos.setMaxKey(maxKey);
return restructureInfos;
}
Aggregations