Search in sources :

Example 1 with DimColumnResolvedFilterInfo

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);
    }
}
Also used : DimColumnResolvedFilterInfo(org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo) RestructureIncludeFilterExecutorImpl(org.apache.carbondata.core.scan.filter.executer.RestructureIncludeFilterExecutorImpl) IncludeColGroupFilterExecuterImpl(org.apache.carbondata.core.scan.filter.executer.IncludeColGroupFilterExecuterImpl) IncludeFilterExecuterImpl(org.apache.carbondata.core.scan.filter.executer.IncludeFilterExecuterImpl) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Example 2 with DimColumnResolvedFilterInfo

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);
    }
}
Also used : DimColumnResolvedFilterInfo(org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo) ExcludeColGroupFilterExecuterImpl(org.apache.carbondata.core.scan.filter.executer.ExcludeColGroupFilterExecuterImpl) ExcludeFilterExecuterImpl(org.apache.carbondata.core.scan.filter.executer.ExcludeFilterExecuterImpl) RestructureExcludeFilterExecutorImpl(org.apache.carbondata.core.scan.filter.executer.RestructureExcludeFilterExecutorImpl) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Example 3 with DimColumnResolvedFilterInfo

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);
}
Also used : MeasureColumnResolvedFilterInfo(org.apache.carbondata.core.scan.filter.resolver.resolverinfo.MeasureColumnResolvedFilterInfo) DimColumnResolvedFilterInfo(org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo) DataOutputStream(java.io.DataOutputStream) DimensionColumnDataChunk(org.apache.carbondata.core.datastore.chunk.DimensionColumnDataChunk) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) MeasureColumnDataChunk(org.apache.carbondata.core.datastore.chunk.MeasureColumnDataChunk) VariableLengthDimensionDataChunk(org.apache.carbondata.core.datastore.chunk.impl.VariableLengthDimensionDataChunk) BigDecimal(java.math.BigDecimal) GenericQueryType(org.apache.carbondata.core.scan.filter.GenericQueryType) DataType(org.apache.carbondata.core.metadata.datatype.DataType)

Example 4 with DimColumnResolvedFilterInfo

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]);
            }
        }
    }
}
Also used : MeasureColumnResolvedFilterInfo(org.apache.carbondata.core.scan.filter.resolver.resolverinfo.MeasureColumnResolvedFilterInfo) DimColumnResolvedFilterInfo(org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo) GenericQueryType(org.apache.carbondata.core.scan.filter.GenericQueryType)

Example 5 with DimColumnResolvedFilterInfo

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);
            }
        }
    }
}
Also used : MeasureColumnResolvedFilterInfo(org.apache.carbondata.core.scan.filter.resolver.resolverinfo.MeasureColumnResolvedFilterInfo) DimColumnResolvedFilterInfo(org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) ConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.ConditionalExpression)

Aggregations

DimColumnResolvedFilterInfo (org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo)6 MeasureColumnResolvedFilterInfo (org.apache.carbondata.core.scan.filter.resolver.resolverinfo.MeasureColumnResolvedFilterInfo)4 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)2 ColumnExpression (org.apache.carbondata.core.scan.expression.ColumnExpression)2 GenericQueryType (org.apache.carbondata.core.scan.filter.GenericQueryType)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataOutputStream (java.io.DataOutputStream)1 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 DimensionColumnDataChunk (org.apache.carbondata.core.datastore.chunk.DimensionColumnDataChunk)1 MeasureColumnDataChunk (org.apache.carbondata.core.datastore.chunk.MeasureColumnDataChunk)1 VariableLengthDimensionDataChunk (org.apache.carbondata.core.datastore.chunk.impl.VariableLengthDimensionDataChunk)1 DataType (org.apache.carbondata.core.metadata.datatype.DataType)1 ConditionalExpression (org.apache.carbondata.core.scan.expression.conditional.ConditionalExpression)1 BinaryLogicalExpression (org.apache.carbondata.core.scan.expression.logical.BinaryLogicalExpression)1 DimColumnFilterInfo (org.apache.carbondata.core.scan.filter.DimColumnFilterInfo)1 ExcludeColGroupFilterExecuterImpl (org.apache.carbondata.core.scan.filter.executer.ExcludeColGroupFilterExecuterImpl)1 ExcludeFilterExecuterImpl (org.apache.carbondata.core.scan.filter.executer.ExcludeFilterExecuterImpl)1 IncludeColGroupFilterExecuterImpl (org.apache.carbondata.core.scan.filter.executer.IncludeColGroupFilterExecuterImpl)1 IncludeFilterExecuterImpl (org.apache.carbondata.core.scan.filter.executer.IncludeFilterExecuterImpl)1