use of org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo in project carbondata by apache.
the class ExcludeColGroupFilterExecuterImpl method getKeyStructureInfo.
/**
* It is required for extracting column data from columngroup chunk
*
* @return
* @throws KeyGenException
*/
private KeyStructureInfo getKeyStructureInfo() throws KeyGenException {
int colGrpId = getColumnGroupId(dimColEvaluatorInfo.getColumnIndex());
KeyGenerator keyGenerator = segmentProperties.getColumnGroupAndItsKeygenartor().get(colGrpId);
List<Integer> mdKeyOrdinal = new ArrayList<Integer>();
mdKeyOrdinal.add(getMdkeyOrdinal(dimColEvaluatorInfo.getColumnIndex(), colGrpId));
int[] maskByteRanges = QueryUtil.getMaskedByteRangeBasedOrdinal(mdKeyOrdinal, keyGenerator);
byte[] maxKey = QueryUtil.getMaxKeyBasedOnOrinal(mdKeyOrdinal, keyGenerator);
KeyStructureInfo restructureInfos = new KeyStructureInfo();
restructureInfos.setKeyGenerator(keyGenerator);
restructureInfos.setMaskByteRanges(maskByteRanges);
restructureInfos.setMaxKey(maxKey);
return restructureInfos;
}
use of org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo in project carbondata by apache.
the class QueryUtil method getColumnGroupKeyStructureInfo.
/**
* Below method will be used to get the mapping of block index and its
* restructuring info
*
* @param queryDimensions query dimension from query model
* @param segmentProperties segment properties
* @return map of block index to its restructuring info
* @throws KeyGenException if problem while key generation
*/
public static Map<Integer, KeyStructureInfo> getColumnGroupKeyStructureInfo(List<ProjectionDimension> queryDimensions, SegmentProperties segmentProperties) throws KeyGenException {
Map<Integer, KeyStructureInfo> rowGroupToItsRSInfo = new HashMap<Integer, KeyStructureInfo>();
// get column group id and its ordinal mapping of column group
Map<Integer, List<Integer>> columnGroupAndItsOrdinalMappingForQuery = getColumnGroupAndItsOrdinalMapping(queryDimensions);
Map<Integer, KeyGenerator> columnGroupAndItsKeygenartor = segmentProperties.getColumnGroupAndItsKeygenartor();
Iterator<Entry<Integer, List<Integer>>> iterator = columnGroupAndItsOrdinalMappingForQuery.entrySet().iterator();
KeyStructureInfo restructureInfos = null;
while (iterator.hasNext()) {
Entry<Integer, List<Integer>> next = iterator.next();
KeyGenerator keyGenerator = columnGroupAndItsKeygenartor.get(next.getKey());
restructureInfos = new KeyStructureInfo();
// sort the ordinal
List<Integer> ordinal = next.getValue();
List<Integer> mdKeyOrdinal = new ArrayList<Integer>();
// Un sorted
List<Integer> mdKeyOrdinalForQuery = new ArrayList<Integer>();
for (Integer ord : ordinal) {
mdKeyOrdinal.add(segmentProperties.getColumnGroupMdKeyOrdinal(next.getKey(), ord));
mdKeyOrdinalForQuery.add(segmentProperties.getColumnGroupMdKeyOrdinal(next.getKey(), ord));
}
Collections.sort(mdKeyOrdinal);
// get the masked byte range for column group
int[] maskByteRanges = getMaskedByteRangeBasedOrdinal(mdKeyOrdinal, keyGenerator);
// max key for column group
byte[] maxKey = getMaxKeyBasedOnOrinal(mdKeyOrdinal, keyGenerator);
restructureInfos.setKeyGenerator(keyGenerator);
restructureInfos.setMaskByteRanges(maskByteRanges);
restructureInfos.setMaxKey(maxKey);
restructureInfos.setMdkeyQueryDimensionOrdinal(ArrayUtils.toPrimitive(mdKeyOrdinalForQuery.toArray(new Integer[mdKeyOrdinalForQuery.size()])));
rowGroupToItsRSInfo.put(segmentProperties.getDimensionOrdinalToChunkMapping().get(ordinal.get(0)), restructureInfos);
}
return rowGroupToItsRSInfo;
}
use of org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo 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(DimensionColumnPage 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, dimensionChunkIndex[0]);
return (int) result[segmentProperties.getColumnGroupMdKeyOrdinal(colGroupId, dimensionChunkIndex[0])];
} catch (KeyGenException e) {
LOGGER.error(e);
}
return 0;
}
use of org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo in project carbondata by apache.
the class FixedLengthDimensionDataChunkTest method fillConvertedChunkDataTest.
@Test
public void fillConvertedChunkDataTest() {
int[] row = { 1, 2, 4, 6 };
KeyStructureInfo keyStructureInfo = new KeyStructureInfo();
int res = fixedLengthDimensionDataChunk.fillSurrogateKey(1, 0, row, keyStructureInfo);
int expectedResult = 1;
assertEquals(res, expectedResult);
}
use of org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo in project carbondata by apache.
the class FixedLengthDimensionDataChunkTest method fillChunkDataTest.
@Test
public void fillChunkDataTest() {
KeyStructureInfo keyStructureInfo = new KeyStructureInfo();
int[] maskByteRanges = { 1, 2, 4, 6, 5 };
keyStructureInfo.setMaskByteRanges(maskByteRanges);
keyStructureInfo.setMaxKey("1234567".getBytes());
int res = fixedLengthDimensionDataChunk.fillRawData(0, 0, data, keyStructureInfo);
int expectedResult = 4;
assertEquals(res, expectedResult);
}
Aggregations