Search in sources :

Example 31 with CarbonMeasure

use of org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure in project carbondata by apache.

the class RowLevelFilterExecuterImpl method initMeasureChunkIndexes.

/**
 * This method will initialize the measure info for the current block to be
 * used for filtering the data
 */
private void initMeasureChunkIndexes() {
    for (int i = 0; i < msrColEvalutorInfoList.size(); i++) {
        // find the measure in the current block measures list
        CarbonMeasure measureFromCurrentBlock = segmentProperties.getMeasureFromCurrentBlock(msrColEvalutorInfoList.get(i).getCarbonColumn().getColumnId());
        if (null != measureFromCurrentBlock) {
            msrColEvalutorInfoList.get(i).setColumnIndex(measureFromCurrentBlock.getOrdinal());
            this.measureChunkIndex[i] = segmentProperties.getMeasuresOrdinalToChunkMapping().get(measureFromCurrentBlock.getOrdinal());
            isMeasurePresentInCurrentBlock[i] = true;
        }
    }
}
Also used : CarbonMeasure(org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure)

Example 32 with CarbonMeasure

use of org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure in project carbondata by apache.

the class RowLevelRangeGrtThanFiterExecuterImpl method ifDefaultValueMatchesFilter.

/**
 * This method will check whether default value is present in the given filter values
 */
private void ifDefaultValueMatchesFilter() {
    if (!dimColEvaluatorInfoList.isEmpty() && !isDimensionPresentInCurrentBlock[0]) {
        CarbonDimension dimension = this.dimColEvaluatorInfoList.get(0).getDimension();
        byte[] defaultValue = dimension.getDefaultValue();
        if (null != defaultValue) {
            for (int k = 0; k < filterRangeValues.length; k++) {
                int maxCompare = ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterRangeValues[k], defaultValue);
                if (maxCompare < 0) {
                    isDefaultValuePresentInFilter = true;
                    break;
                }
            }
        }
    } else if (!msrColEvalutorInfoList.isEmpty() && !isMeasurePresentInCurrentBlock[0]) {
        CarbonMeasure measure = this.msrColEvalutorInfoList.get(0).getMeasure();
        byte[] defaultValue = measure.getDefaultValue();
        if (null != defaultValue) {
            for (int k = 0; k < msrFilterRangeValues.length; k++) {
                int maxCompare = comparator.compare(msrFilterRangeValues[k], DataTypeUtil.getMeasureObjectFromDataType(defaultValue, measure.getDataType()));
                if (maxCompare < 0) {
                    isDefaultValuePresentInFilter = true;
                    break;
                }
            }
        }
    }
}
Also used : CarbonMeasure(org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Example 33 with CarbonMeasure

use of org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure in project carbondata by apache.

the class RowLevelRangeLessThanEqualFilterExecuterImpl method ifDefaultValueMatchesFilter.

/**
 * This method will check whether default value is present in the given filter values
 */
private void ifDefaultValueMatchesFilter() {
    if (!dimColEvaluatorInfoList.isEmpty() && !isDimensionPresentInCurrentBlock[0]) {
        CarbonDimension dimension = this.dimColEvaluatorInfoList.get(0).getDimension();
        byte[] defaultValue = dimension.getDefaultValue();
        if (null != defaultValue) {
            for (int k = 0; k < filterRangeValues.length; k++) {
                int maxCompare = ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterRangeValues[k], defaultValue);
                if (maxCompare >= 0) {
                    isDefaultValuePresentInFilter = true;
                    break;
                }
            }
        }
    } else if (!msrColEvalutorInfoList.isEmpty() && !isMeasurePresentInCurrentBlock[0]) {
        CarbonMeasure measure = this.msrColEvalutorInfoList.get(0).getMeasure();
        byte[] defaultValue = measure.getDefaultValue();
        if (null != defaultValue) {
            for (int k = 0; k < msrFilterRangeValues.length; k++) {
                int maxCompare = comparator.compare(msrFilterRangeValues[k], DataTypeUtil.getMeasureObjectFromDataType(defaultValue, measure.getDataType()));
                if (maxCompare >= 0) {
                    isDefaultValuePresentInFilter = true;
                    break;
                }
            }
        }
    }
}
Also used : CarbonMeasure(org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Example 34 with CarbonMeasure

use of org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure in project carbondata by apache.

the class RowLevelRangeLessThanFiterExecuterImpl method ifDefaultValueMatchesFilter.

/**
 * This method will check whether default value is present in the given filter values
 */
private void ifDefaultValueMatchesFilter() {
    if (!dimColEvaluatorInfoList.isEmpty() && !isDimensionPresentInCurrentBlock[0]) {
        CarbonDimension dimension = this.dimColEvaluatorInfoList.get(0).getDimension();
        byte[] defaultValue = dimension.getDefaultValue();
        if (null != defaultValue) {
            for (int k = 0; k < filterRangeValues.length; k++) {
                int maxCompare = ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterRangeValues[k], defaultValue);
                if (maxCompare > 0) {
                    isDefaultValuePresentInFilter = true;
                    break;
                }
            }
        }
    } else if (!msrColEvalutorInfoList.isEmpty() && !isMeasurePresentInCurrentBlock[0]) {
        CarbonMeasure measure = this.msrColEvalutorInfoList.get(0).getMeasure();
        byte[] defaultValue = measure.getDefaultValue();
        if (null != defaultValue) {
            for (int k = 0; k < msrFilterRangeValues.length; k++) {
                Object convertedValue = DataTypeUtil.getMeasureObjectFromDataType(defaultValue, measure.getDataType());
                int maxCompare = comparator.compare(msrFilterRangeValues[k], convertedValue);
                if (maxCompare > 0) {
                    isDefaultValuePresentInFilter = true;
                    break;
                }
            }
        }
    }
}
Also used : CarbonMeasure(org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Example 35 with CarbonMeasure

use of org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure in project carbondata by apache.

the class QueryModelBuilder method build.

public QueryModel build(Expression filterExpression) {
    QueryProjection projection = new QueryProjection();
    List<CarbonDimension> dimensions = carbonTable.getDimensions();
    for (int i = 0; i < dimensions.size(); i++) {
        projection.addDimension(dimensions.get(i), i);
    }
    List<CarbonMeasure> measures = carbonTable.getMeasures();
    for (int i = 0; i < measures.size(); i++) {
        projection.addMeasure(measures.get(i), i);
    }
    QueryModel queryModel = QueryModel.newInstance(carbonTable);
    queryModel.setProjection(projection);
    boolean[] isFilterDimensions = new boolean[carbonTable.getDimensionOrdinalMax()];
    boolean[] isFilterMeasures = new boolean[carbonTable.getAllMeasures().size()];
    carbonTable.processFilterExpression(filterExpression, isFilterDimensions, isFilterMeasures);
    queryModel.setIsFilterDimensions(isFilterDimensions);
    queryModel.setIsFilterMeasures(isFilterMeasures);
    FilterResolverIntf filterIntf = carbonTable.resolveFilter(filterExpression, null);
    queryModel.setFilterExpressionResolverTree(filterIntf);
    return queryModel;
}
Also used : CarbonMeasure(org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure) FilterResolverIntf(org.apache.carbondata.core.scan.filter.resolver.FilterResolverIntf) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Aggregations

CarbonMeasure (org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure)47 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)31 ArrayList (java.util.ArrayList)16 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)10 DataType (org.apache.carbondata.core.metadata.datatype.DataType)8 CarbonColumn (org.apache.carbondata.core.metadata.schema.table.column.CarbonColumn)7 HashSet (java.util.HashSet)5 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)4 BlockExecutionInfo (org.apache.carbondata.core.scan.executor.infos.BlockExecutionInfo)4 ProjectionMeasure (org.apache.carbondata.core.scan.model.ProjectionMeasure)4 Test (org.junit.Test)4 MeasureInfo (org.apache.carbondata.core.scan.executor.infos.MeasureInfo)3 QueryDimension (org.apache.carbondata.core.scan.model.QueryDimension)3 QueryMeasure (org.apache.carbondata.core.scan.model.QueryMeasure)3 GenericDataType (org.apache.carbondata.processing.datatypes.GenericDataType)3 BufferedReader (java.io.BufferedReader)2 FileReader (java.io.FileReader)2 ByteBuffer (java.nio.ByteBuffer)2 HashMap (java.util.HashMap)2 LinkedHashSet (java.util.LinkedHashSet)2