Search in sources :

Example 1 with SerializableComparator

use of org.apache.carbondata.core.util.comparator.SerializableComparator in project carbondata by apache.

the class FilterUtil method getMeasureValKeyMemberForFilter.

/**
 * This method will get the no dictionary data based on filters and same
 * will be in ColumnFilterInfo
 *
 * @param evaluateResultListFinal
 * @param isIncludeFilter
 * @return ColumnFilterInfo
 */
public static ColumnFilterInfo getMeasureValKeyMemberForFilter(List<String> evaluateResultListFinal, boolean isIncludeFilter, DataType dataType, CarbonMeasure carbonMeasure) throws FilterUnsupportedException {
    List<Object> filterValuesList = new ArrayList<>(20);
    String result = null;
    try {
        int length = evaluateResultListFinal.size();
        for (int i = 0; i < length; i++) {
            result = evaluateResultListFinal.get(i);
            if (CarbonCommonConstants.MEMBER_DEFAULT_VAL.equals(result)) {
                filterValuesList.add(null);
                continue;
            }
            filterValuesList.add(DataTypeUtil.getMeasureValueBasedOnDataType(result, dataType, carbonMeasure));
        }
    } catch (Throwable ex) {
        throw new FilterUnsupportedException("Unsupported Filter condition: " + result, ex);
    }
    SerializableComparator filterMeasureComaparator = Comparator.getComparatorByDataTypeForMeasure(dataType);
    Collections.sort(filterValuesList, filterMeasureComaparator);
    ColumnFilterInfo columnFilterInfo = null;
    if (filterValuesList.size() > 0) {
        columnFilterInfo = new ColumnFilterInfo();
        columnFilterInfo.setIncludeFilter(isIncludeFilter);
        columnFilterInfo.setMeasuresFilterValuesList(filterValuesList);
    }
    return columnFilterInfo;
}
Also used : SerializableComparator(org.apache.carbondata.core.util.comparator.SerializableComparator) ArrayList(java.util.ArrayList) FilterUnsupportedException(org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException)

Example 2 with SerializableComparator

use of org.apache.carbondata.core.util.comparator.SerializableComparator in project carbondata by apache.

the class ExcludeFilterExecuterImpl method getFilteredIndexes.

private BitSet getFilteredIndexes(ColumnPage columnPage, int numerOfRows, DataType msrType) {
    // Here the algorithm is
    // Get the measure values from the chunk. compare sequentially with the
    // the filter values. The one that matches sets it Bitset.
    BitSet bitSet = new BitSet(numerOfRows);
    bitSet.flip(0, numerOfRows);
    Object[] filterValues = msrColumnExecutorInfo.getFilterKeys();
    SerializableComparator comparator = Comparator.getComparatorByDataTypeForMeasure(msrType);
    for (int i = 0; i < filterValues.length; i++) {
        BitSet nullBitSet = columnPage.getNullBits();
        if (filterValues[i] == null) {
            for (int j = nullBitSet.nextSetBit(0); j >= 0; j = nullBitSet.nextSetBit(j + 1)) {
                bitSet.flip(j);
            }
            continue;
        }
        for (int startIndex = 0; startIndex < numerOfRows; startIndex++) {
            if (!nullBitSet.get(startIndex)) {
                // Check if filterValue[i] matches with measure Values.
                Object msrValue = DataTypeUtil.getMeasureObjectBasedOnDataType(columnPage, startIndex, msrType, msrColumnEvaluatorInfo.getMeasure());
                if (comparator.compare(msrValue, filterValues[i]) == 0) {
                    // This is a match.
                    bitSet.flip(startIndex);
                }
            }
        }
    }
    return bitSet;
}
Also used : SerializableComparator(org.apache.carbondata.core.util.comparator.SerializableComparator) BitSet(java.util.BitSet)

Example 3 with SerializableComparator

use of org.apache.carbondata.core.util.comparator.SerializableComparator in project carbondata by apache.

the class ExcludeFilterExecuterImpl method getFilteredIndexesForMsrUsingPrvBitSet.

/**
 * Below method will be used to apply filter on measure column based on previous filtered indexes
 * @param measureColumnPage
 * @param prvBitSetGroup
 * @param pageNumber
 * @param numberOfRows
 * @param msrDataType
 * @return filtred indexes bitset
 */
private BitSet getFilteredIndexesForMsrUsingPrvBitSet(ColumnPage measureColumnPage, BitSetGroup prvBitSetGroup, int pageNumber, int numberOfRows, DataType msrDataType) {
    BitSet bitSet = new BitSet(numberOfRows);
    bitSet.flip(0, numberOfRows);
    Object[] filterValues = msrColumnExecutorInfo.getFilterKeys();
    BitSet nullBitSet = measureColumnPage.getNullBits();
    BitSet prvPageBitSet = prvBitSetGroup.getBitSet(pageNumber);
    SerializableComparator comparator = Comparator.getComparatorByDataTypeForMeasure(msrDataType);
    for (int i = 0; i < filterValues.length; i++) {
        if (filterValues[i] == null) {
            for (int j = nullBitSet.nextSetBit(0); j >= 0; j = nullBitSet.nextSetBit(j + 1)) {
                bitSet.flip(j);
            }
            continue;
        }
        for (int index = prvPageBitSet.nextSetBit(0); index >= 0; index = prvPageBitSet.nextSetBit(index + 1)) {
            if (!nullBitSet.get(index)) {
                // Check if filterValue[i] matches with measure Values.
                Object msrValue = DataTypeUtil.getMeasureObjectBasedOnDataType(measureColumnPage, index, msrDataType, msrColumnEvaluatorInfo.getMeasure());
                if (comparator.compare(msrValue, filterValues[i]) == 0) {
                    // This is a match.
                    bitSet.flip(index);
                }
            }
        }
    }
    return bitSet;
}
Also used : SerializableComparator(org.apache.carbondata.core.util.comparator.SerializableComparator) BitSet(java.util.BitSet)

Example 4 with SerializableComparator

use of org.apache.carbondata.core.util.comparator.SerializableComparator in project carbondata by apache.

the class RowLevelRangeGrtrThanEquaToFilterExecuterImpl method getFilteredIndexesForMeasures.

private BitSet getFilteredIndexesForMeasures(ColumnPage columnPage, int numerOfRows) {
    BitSet bitSet = new BitSet(numerOfRows);
    Object[] filterValues = this.msrFilterRangeValues;
    DataType msrType = msrColEvalutorInfoList.get(0).getType();
    SerializableComparator comparator = Comparator.getComparatorByDataTypeForMeasure(msrType);
    BitSet nullBitSet = columnPage.getNullBits();
    for (int i = 0; i < filterValues.length; i++) {
        if (filterValues[i] == null) {
            for (int j = nullBitSet.nextSetBit(0); j >= 0; j = nullBitSet.nextSetBit(j + 1)) {
                bitSet.set(j);
            }
            continue;
        }
        for (int startIndex = 0; startIndex < numerOfRows; startIndex++) {
            if (!nullBitSet.get(startIndex)) {
                Object msrValue = DataTypeUtil.getMeasureObjectBasedOnDataType(columnPage, startIndex, msrType, msrColEvalutorInfoList.get(0).getMeasure());
                if (comparator.compare(msrValue, filterValues[i]) >= 0) {
                    // This is a match.
                    bitSet.set(startIndex);
                }
            }
        }
    }
    return bitSet;
}
Also used : SerializableComparator(org.apache.carbondata.core.util.comparator.SerializableComparator) BitSet(java.util.BitSet) DataType(org.apache.carbondata.core.metadata.datatype.DataType)

Example 5 with SerializableComparator

use of org.apache.carbondata.core.util.comparator.SerializableComparator in project carbondata by apache.

the class RowLevelRangeLessThanEqualFilterExecuterImpl method getFilteredIndexesForMeasures.

private BitSet getFilteredIndexesForMeasures(ColumnPage columnPage, int numerOfRows) {
    BitSet bitSet = new BitSet(numerOfRows);
    Object[] filterValues = this.msrFilterRangeValues;
    DataType msrType = msrColEvalutorInfoList.get(0).getType();
    SerializableComparator comparator = Comparator.getComparatorByDataTypeForMeasure(msrType);
    BitSet nullBitSet = columnPage.getNullBits();
    for (int i = 0; i < filterValues.length; i++) {
        if (filterValues[i] == null) {
            for (int j = nullBitSet.nextSetBit(0); j >= 0; j = nullBitSet.nextSetBit(j + 1)) {
                bitSet.set(j);
            }
            continue;
        }
        for (int startIndex = 0; startIndex < numerOfRows; startIndex++) {
            if (!nullBitSet.get(startIndex)) {
                Object msrValue = DataTypeUtil.getMeasureObjectBasedOnDataType(columnPage, startIndex, msrType, msrColEvalutorInfoList.get(0).getMeasure());
                if (comparator.compare(msrValue, filterValues[i]) <= 0) {
                    // This is a match.
                    bitSet.set(startIndex);
                }
            }
        }
    }
    return bitSet;
}
Also used : SerializableComparator(org.apache.carbondata.core.util.comparator.SerializableComparator) BitSet(java.util.BitSet) DataType(org.apache.carbondata.core.metadata.datatype.DataType)

Aggregations

SerializableComparator (org.apache.carbondata.core.util.comparator.SerializableComparator)13 BitSet (java.util.BitSet)10 DataType (org.apache.carbondata.core.metadata.datatype.DataType)7 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CarbonMeasure (org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure)1 FilterUnsupportedException (org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException)1 ColumnFilterInfo (org.apache.carbondata.core.scan.filter.ColumnFilterInfo)1