use of org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo in project carbondata by apache.
the class FilterUtil method getIncludeFilterExecuter.
/**
* It gives filter executer based on columnar or column group
*
* @param dimColResolvedFilterInfo
* @param segmentProperties
* @return
*/
private static FilterExecuter getIncludeFilterExecuter(DimColumnResolvedFilterInfo dimColResolvedFilterInfo, SegmentProperties segmentProperties) {
if (dimColResolvedFilterInfo.getDimension().isColumnar()) {
CarbonDimension dimensionFromCurrentBlock = segmentProperties.getDimensionFromCurrentBlock(dimColResolvedFilterInfo.getDimension());
if (null != dimensionFromCurrentBlock) {
// update dimension and column index according to the dimension position in current block
DimColumnResolvedFilterInfo dimColResolvedFilterInfoCopyObject = dimColResolvedFilterInfo.getCopyObject();
dimColResolvedFilterInfoCopyObject.setDimension(dimensionFromCurrentBlock);
dimColResolvedFilterInfoCopyObject.setColumnIndex(dimensionFromCurrentBlock.getOrdinal());
return new IncludeFilterExecuterImpl(dimColResolvedFilterInfoCopyObject, segmentProperties);
} else {
return new RestructureIncludeFilterExecutorImpl(dimColResolvedFilterInfo, segmentProperties);
}
} else {
return new IncludeColGroupFilterExecuterImpl(dimColResolvedFilterInfo, segmentProperties);
}
}
use of org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo in project carbondata by apache.
the class FilterUtil method getExcludeFilterExecuter.
/**
* It gives filter executer based on columnar or column group
*
* @param dimColResolvedFilterInfo
* @param segmentProperties
* @return
*/
private static FilterExecuter getExcludeFilterExecuter(DimColumnResolvedFilterInfo dimColResolvedFilterInfo, SegmentProperties segmentProperties) {
if (dimColResolvedFilterInfo.getDimension().isColumnar()) {
CarbonDimension dimensionFromCurrentBlock = segmentProperties.getDimensionFromCurrentBlock(dimColResolvedFilterInfo.getDimension());
if (null != dimensionFromCurrentBlock) {
// update dimension and column index according to the dimension position in current block
DimColumnResolvedFilterInfo dimColResolvedFilterInfoCopyObject = dimColResolvedFilterInfo.getCopyObject();
dimColResolvedFilterInfoCopyObject.setDimension(dimensionFromCurrentBlock);
dimColResolvedFilterInfoCopyObject.setColumnIndex(dimensionFromCurrentBlock.getOrdinal());
return new ExcludeFilterExecuterImpl(dimColResolvedFilterInfoCopyObject, segmentProperties);
} else {
return new RestructureExcludeFilterExecutorImpl(dimColResolvedFilterInfo, segmentProperties);
}
} else {
return new ExcludeColGroupFilterExecuterImpl(dimColResolvedFilterInfo, segmentProperties);
}
}
use of org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo in project carbondata by apache.
the class RowLevelFilterExecuterImpl method createRow.
/**
* Method will read the members of particular dimension block and create
* a row instance for further processing of the filters
*
* @param blockChunkHolder
* @param row
* @param index
* @throws IOException
*/
private void createRow(BlocksChunkHolder blockChunkHolder, RowIntf row, int pageIndex, int index) throws IOException {
Object[] record = new Object[dimColEvaluatorInfoList.size() + msrColEvalutorInfoList.size()];
String memberString;
for (int i = 0; i < dimColEvaluatorInfoList.size(); i++) {
DimColumnResolvedFilterInfo dimColumnEvaluatorInfo = dimColEvaluatorInfoList.get(i);
// if filter dimension is not present in the current add its default value
if (!isDimensionPresentInCurrentBlock[i]) {
// fill default value here
record[dimColumnEvaluatorInfo.getRowIndex()] = getDimensionDefaultValue(dimColumnEvaluatorInfo);
continue;
}
if (dimColumnEvaluatorInfo.getDimension().getDataType() != DataType.ARRAY && dimColumnEvaluatorInfo.getDimension().getDataType() != DataType.STRUCT) {
if (!dimColumnEvaluatorInfo.isDimensionExistsInCurrentSilce()) {
record[dimColumnEvaluatorInfo.getRowIndex()] = dimColumnEvaluatorInfo.getDimension().getDefaultValue();
}
DimensionColumnDataChunk columnDataChunk = blockChunkHolder.getDimensionRawDataChunk()[dimensionBlocksIndex[i]].convertToDimColDataChunk(pageIndex);
if (!dimColumnEvaluatorInfo.getDimension().hasEncoding(Encoding.DICTIONARY) && columnDataChunk instanceof VariableLengthDimensionDataChunk) {
VariableLengthDimensionDataChunk dimensionColumnDataChunk = (VariableLengthDimensionDataChunk) columnDataChunk;
byte[] memberBytes = dimensionColumnDataChunk.getChunkData(index);
if (null != memberBytes) {
if (Arrays.equals(CarbonCommonConstants.MEMBER_DEFAULT_VAL_ARRAY, memberBytes)) {
memberBytes = null;
}
record[dimColumnEvaluatorInfo.getRowIndex()] = DataTypeUtil.getDataBasedOnDataTypeForNoDictionaryColumn(memberBytes, dimColumnEvaluatorInfo.getDimension().getDataType());
} else {
continue;
}
} else {
int dictionaryValue = readSurrogatesFromColumnBlock(blockChunkHolder, index, pageIndex, dimColumnEvaluatorInfo, dimensionBlocksIndex[i]);
if (dimColumnEvaluatorInfo.getDimension().hasEncoding(Encoding.DICTIONARY) && !dimColumnEvaluatorInfo.getDimension().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
memberString = getFilterActualValueFromDictionaryValue(dimColumnEvaluatorInfo, dictionaryValue);
record[dimColumnEvaluatorInfo.getRowIndex()] = DataTypeUtil.getDataBasedOnDataType(memberString, dimColumnEvaluatorInfo.getDimension().getDataType());
} else if (dimColumnEvaluatorInfo.getDimension().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
Object member = getFilterActualValueFromDirectDictionaryValue(dimColumnEvaluatorInfo, dictionaryValue);
record[dimColumnEvaluatorInfo.getRowIndex()] = member;
}
}
} else {
try {
GenericQueryType complexType = complexDimensionInfoMap.get(dimensionBlocksIndex[i]);
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
DataOutputStream dataOutputStream = new DataOutputStream(byteStream);
complexType.parseBlocksAndReturnComplexColumnByteArray(blockChunkHolder.getDimensionRawDataChunk(), index, pageIndex, dataOutputStream);
record[dimColumnEvaluatorInfo.getRowIndex()] = complexType.getDataBasedOnDataTypeFromSurrogates(ByteBuffer.wrap(byteStream.toByteArray()));
byteStream.close();
} catch (IOException e) {
LOGGER.info(e.getMessage());
}
}
}
DataType msrType;
for (int i = 0; i < msrColEvalutorInfoList.size(); i++) {
MeasureColumnResolvedFilterInfo msrColumnEvalutorInfo = msrColEvalutorInfoList.get(i);
switch(msrColumnEvalutorInfo.getType()) {
case SHORT:
msrType = DataType.SHORT;
break;
case INT:
msrType = DataType.INT;
break;
case LONG:
msrType = DataType.LONG;
break;
case DECIMAL:
msrType = DataType.DECIMAL;
break;
default:
msrType = DataType.DOUBLE;
}
// in the current block measure list
if (!isMeasurePresentInCurrentBlock[i]) {
byte[] defaultValue = msrColumnEvalutorInfo.getCarbonColumn().getDefaultValue();
record[msrColumnEvalutorInfo.getRowIndex()] = RestructureUtil.getMeasureDefaultValue(msrColumnEvalutorInfo.getCarbonColumn().getColumnSchema(), defaultValue);
continue;
}
Object msrValue;
MeasureColumnDataChunk measureColumnDataChunk = blockChunkHolder.getMeasureRawDataChunk()[measureBlocksIndex[0]].convertToMeasureColDataChunk(pageIndex);
switch(msrType) {
case SHORT:
msrValue = (short) measureColumnDataChunk.getMeasureDataHolder().getReadableLongValueByIndex(index);
break;
case INT:
msrValue = (int) measureColumnDataChunk.getMeasureDataHolder().getReadableLongValueByIndex(index);
break;
case LONG:
msrValue = measureColumnDataChunk.getMeasureDataHolder().getReadableLongValueByIndex(index);
break;
case DECIMAL:
BigDecimal bigDecimalValue = measureColumnDataChunk.getMeasureDataHolder().getReadableBigDecimalValueByIndex(index);
if (null != bigDecimalValue && msrColumnEvalutorInfo.getCarbonColumn().getColumnSchema().getScale() > bigDecimalValue.scale()) {
bigDecimalValue = bigDecimalValue.setScale(msrColumnEvalutorInfo.getCarbonColumn().getColumnSchema().getScale(), RoundingMode.HALF_UP);
}
msrValue = bigDecimalValue;
break;
default:
msrValue = measureColumnDataChunk.getMeasureDataHolder().getReadableDoubleValueByIndex(index);
}
record[msrColumnEvalutorInfo.getRowIndex()] = measureColumnDataChunk.getNullValueIndexHolder().getBitSet().get(index) ? null : msrValue;
}
row.setValues(record);
}
use of org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo in project carbondata by apache.
the class RowLevelFilterExecuterImpl method readBlocks.
@Override
public void readBlocks(BlocksChunkHolder blockChunkHolder) throws IOException {
for (int i = 0; i < dimColEvaluatorInfoList.size(); i++) {
DimColumnResolvedFilterInfo dimColumnEvaluatorInfo = dimColEvaluatorInfoList.get(i);
if (dimColumnEvaluatorInfo.getDimension().getDataType() != DataType.ARRAY && dimColumnEvaluatorInfo.getDimension().getDataType() != DataType.STRUCT) {
if (null == blockChunkHolder.getDimensionRawDataChunk()[dimensionBlocksIndex[i]]) {
blockChunkHolder.getDimensionRawDataChunk()[dimensionBlocksIndex[i]] = blockChunkHolder.getDataBlock().getDimensionChunk(blockChunkHolder.getFileReader(), dimensionBlocksIndex[i]);
}
} else {
GenericQueryType complexType = complexDimensionInfoMap.get(dimensionBlocksIndex[i]);
complexType.fillRequiredBlockData(blockChunkHolder);
}
}
if (null != msrColEvalutorInfoList) {
for (MeasureColumnResolvedFilterInfo msrColumnEvalutorInfo : msrColEvalutorInfoList) {
if (null == blockChunkHolder.getMeasureRawDataChunk()[measureBlocksIndex[0]]) {
blockChunkHolder.getMeasureRawDataChunk()[measureBlocksIndex[0]] = blockChunkHolder.getDataBlock().getMeasureChunk(blockChunkHolder.getFileReader(), measureBlocksIndex[0]);
}
}
}
}
use of org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo in project carbondata by apache.
the class RowLevelFilterResolverImpl method resolve.
/**
* Method which will resolve the filter expression by converting the filter member
* to its assigned dictionary values.
*/
public void resolve(AbsoluteTableIdentifier absoluteTableIdentifier) {
DimColumnResolvedFilterInfo dimColumnEvaluatorInfo = null;
MeasureColumnResolvedFilterInfo msrColumnEvalutorInfo = null;
int index = 0;
if (exp instanceof ConditionalExpression) {
ConditionalExpression conditionalExpression = (ConditionalExpression) exp;
List<ColumnExpression> columnList = conditionalExpression.getColumnList();
for (ColumnExpression columnExpression : columnList) {
if (columnExpression.isDimension()) {
dimColumnEvaluatorInfo = new DimColumnResolvedFilterInfo();
dimColumnEvaluatorInfo.setColumnIndex(columnExpression.getCarbonColumn().getOrdinal());
dimColumnEvaluatorInfo.setRowIndex(index++);
dimColumnEvaluatorInfo.setDimension(columnExpression.getDimension());
dimColumnEvaluatorInfo.setDimensionExistsInCurrentSilce(false);
dimColEvaluatorInfoList.add(dimColumnEvaluatorInfo);
} else {
msrColumnEvalutorInfo = new MeasureColumnResolvedFilterInfo();
msrColumnEvalutorInfo.setCarbonColumn(columnExpression.getCarbonColumn());
msrColumnEvalutorInfo.setRowIndex(index++);
msrColumnEvalutorInfo.setColumnIndex(columnExpression.getCarbonColumn().getOrdinal());
msrColumnEvalutorInfo.setType(columnExpression.getCarbonColumn().getDataType());
msrColEvalutorInfoList.add(msrColumnEvalutorInfo);
}
}
}
}
Aggregations