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(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.scan.executor.infos.KeyStructureInfo in project carbondata by apache.
the class ExcludeColGroupFilterExecuterImpl method getFilteredIndexes.
/**
* It fills BitSet with row index which matches filter key
*/
protected BitSet getFilteredIndexes(DimensionColumnDataChunk dimensionColumnDataChunk, int numerOfRows) {
BitSet bitSet = new BitSet(numerOfRows);
bitSet.flip(0, numerOfRows);
try {
KeyStructureInfo keyStructureInfo = getKeyStructureInfo();
byte[][] filterValues = dimColumnExecuterInfo.getFilterKeys();
for (int i = 0; i < filterValues.length; i++) {
byte[] filterVal = filterValues[i];
for (int rowId = 0; rowId < numerOfRows; rowId++) {
byte[] colData = new byte[keyStructureInfo.getMaskByteRanges().length];
dimensionColumnDataChunk.fillChunkData(colData, 0, rowId, keyStructureInfo);
if (ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterVal, colData) == 0) {
bitSet.flip(rowId);
}
}
}
} catch (Exception e) {
LOGGER.error(e);
}
return bitSet;
}
use of org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo in project carbondata by apache.
the class ColumnGroupDimensionDataChunkTest method fillConvertedChunkDataTest.
@Test
public void fillConvertedChunkDataTest() {
int[] row = new int[3];
int[] expected = { 0, 0, 3 };
List<Integer> ordinals = new ArrayList<Integer>();
ordinals.add(2);
KeyStructureInfo keyStructureInfo = getKeyStructureInfo(ordinals, keyGenerator);
keyStructureInfo.setMdkeyQueryDimensionOrdinal(new int[] { 2 });
int res = columnGroupDimensionDataChunk.fillConvertedChunkData(2, 2, row, keyStructureInfo);
assert (Arrays.equals(row, expected));
}
use of org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo 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;
}
use of org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo in project carbondata by apache.
the class ColumnGroupDimensionDataChunkTest method fillChunkDataTest.
@Test
public void fillChunkDataTest() {
List<Integer> ordinals = new ArrayList<Integer>();
ordinals.add(1);
KeyStructureInfo keyStructureInfo = getKeyStructureInfo(ordinals, keyGenerator);
byte[] buffer = new byte[1];
columnGroupDimensionDataChunk.fillChunkData(buffer, 0, 1, keyStructureInfo);
assertEquals(buffer[0], 2);
}
Aggregations