Search in sources :

Example 1 with ExcludeFilterExecutorImpl

use of org.apache.carbondata.core.scan.filter.executer.ExcludeFilterExecutorImpl in project carbondata by apache.

the class FilterUtil method getFilterExecutorForRangeFilters.

/**
 * Below method will be used to get filter executor instance for range filters
 * when local dictionary is present for in blocklet
 * @param rawColumnChunk
 * raw column chunk
 * @param exp
 * filter expression
 * @param isNaturalSorted
 * is data was already sorted
 * @return
 */
public static FilterExecutor getFilterExecutorForRangeFilters(DimensionRawColumnChunk rawColumnChunk, Expression exp, boolean isNaturalSorted) {
    BitSet includeDictionaryValues;
    try {
        includeDictionaryValues = FilterUtil.getIncludeDictFilterValuesForRange(exp, rawColumnChunk.getLocalDictionary());
    } catch (FilterUnsupportedException e) {
        throw new RuntimeException(e);
    }
    boolean isExclude = includeDictionaryValues.cardinality() > 1 && FilterUtil.isExcludeFilterNeedsToApply(rawColumnChunk.getLocalDictionary().getDictionaryActualSize(), includeDictionaryValues.cardinality());
    byte[][] encodedFilterValues = FilterUtil.getEncodedFilterValuesForRange(includeDictionaryValues, rawColumnChunk.getLocalDictionary(), isExclude);
    FilterExecutor filterExecutor;
    if (!isExclude) {
        filterExecutor = new IncludeFilterExecutorImpl(encodedFilterValues, isNaturalSorted);
    } else {
        filterExecutor = new ExcludeFilterExecutorImpl(encodedFilterValues, isNaturalSorted);
    }
    return filterExecutor;
}
Also used : RestructureExcludeFilterExecutorImpl(org.apache.carbondata.core.scan.filter.executer.RestructureExcludeFilterExecutorImpl) ExcludeFilterExecutorImpl(org.apache.carbondata.core.scan.filter.executer.ExcludeFilterExecutorImpl) TrueFilterExecutor(org.apache.carbondata.core.scan.filter.executer.TrueFilterExecutor) FilterExecutor(org.apache.carbondata.core.scan.filter.executer.FilterExecutor) FalseFilterExecutor(org.apache.carbondata.core.scan.filter.executer.FalseFilterExecutor) RestructureIncludeFilterExecutorImpl(org.apache.carbondata.core.scan.filter.executer.RestructureIncludeFilterExecutorImpl) ImplicitIncludeFilterExecutorImpl(org.apache.carbondata.core.scan.filter.executer.ImplicitIncludeFilterExecutorImpl) IncludeFilterExecutorImpl(org.apache.carbondata.core.scan.filter.executer.IncludeFilterExecutorImpl) BitSet(java.util.BitSet) FilterUnsupportedException(org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException)

Example 2 with ExcludeFilterExecutorImpl

use of org.apache.carbondata.core.scan.filter.executer.ExcludeFilterExecutorImpl in project carbondata by apache.

the class FilterUtil method getExcludeFilterExecutor.

/**
 * It gives filter executor based on columnar or column group
 *
 * @param dimColResolvedFilterInfo
 * @param segmentProperties
 * @return
 */
private static FilterExecutor getExcludeFilterExecutor(DimColumnResolvedFilterInfo dimColResolvedFilterInfo, MeasureColumnResolvedFilterInfo msrColResolvedFilterInfo, SegmentProperties segmentProperties) {
    if (null != msrColResolvedFilterInfo && msrColResolvedFilterInfo.getMeasure().isMeasure()) {
        CarbonMeasure measuresFromCurrentBlock = segmentProperties.getMeasureFromCurrentBlock(msrColResolvedFilterInfo.getMeasure());
        if (null != measuresFromCurrentBlock) {
            // update dimension and column index according to the dimension position in current block
            MeasureColumnResolvedFilterInfo msrColResolvedFilterInfoCopyObject = msrColResolvedFilterInfo.getCopyObject();
            msrColResolvedFilterInfoCopyObject.setMeasure(measuresFromCurrentBlock);
            msrColResolvedFilterInfoCopyObject.setColumnIndex(measuresFromCurrentBlock.getOrdinal());
            msrColResolvedFilterInfoCopyObject.setType(measuresFromCurrentBlock.getDataType());
            return new ExcludeFilterExecutorImpl(null, msrColResolvedFilterInfoCopyObject, segmentProperties, true);
        } else {
            return new RestructureExcludeFilterExecutorImpl(dimColResolvedFilterInfo, msrColResolvedFilterInfo, true);
        }
    }
    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 ExcludeFilterExecutorImpl(dimColResolvedFilterInfoCopyObject, null, segmentProperties, false);
    } else {
        return new RestructureExcludeFilterExecutorImpl(dimColResolvedFilterInfo, msrColResolvedFilterInfo, false);
    }
}
Also used : MeasureColumnResolvedFilterInfo(org.apache.carbondata.core.scan.filter.resolver.resolverinfo.MeasureColumnResolvedFilterInfo) RestructureExcludeFilterExecutorImpl(org.apache.carbondata.core.scan.filter.executer.RestructureExcludeFilterExecutorImpl) ExcludeFilterExecutorImpl(org.apache.carbondata.core.scan.filter.executer.ExcludeFilterExecutorImpl) DimColumnResolvedFilterInfo(org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo) CarbonMeasure(org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure) RestructureExcludeFilterExecutorImpl(org.apache.carbondata.core.scan.filter.executer.RestructureExcludeFilterExecutorImpl) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Aggregations

ExcludeFilterExecutorImpl (org.apache.carbondata.core.scan.filter.executer.ExcludeFilterExecutorImpl)2 RestructureExcludeFilterExecutorImpl (org.apache.carbondata.core.scan.filter.executer.RestructureExcludeFilterExecutorImpl)2 BitSet (java.util.BitSet)1 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)1 CarbonMeasure (org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure)1 FilterUnsupportedException (org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException)1 FalseFilterExecutor (org.apache.carbondata.core.scan.filter.executer.FalseFilterExecutor)1 FilterExecutor (org.apache.carbondata.core.scan.filter.executer.FilterExecutor)1 ImplicitIncludeFilterExecutorImpl (org.apache.carbondata.core.scan.filter.executer.ImplicitIncludeFilterExecutorImpl)1 IncludeFilterExecutorImpl (org.apache.carbondata.core.scan.filter.executer.IncludeFilterExecutorImpl)1 RestructureIncludeFilterExecutorImpl (org.apache.carbondata.core.scan.filter.executer.RestructureIncludeFilterExecutorImpl)1 TrueFilterExecutor (org.apache.carbondata.core.scan.filter.executer.TrueFilterExecutor)1 DimColumnResolvedFilterInfo (org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo)1 MeasureColumnResolvedFilterInfo (org.apache.carbondata.core.scan.filter.resolver.resolverinfo.MeasureColumnResolvedFilterInfo)1