Search in sources :

Example 1 with RowIntf

use of org.apache.carbondata.core.scan.filter.intf.RowIntf in project carbondata by apache.

the class AndExpressionTest method testEvaluate.

@Test
public void testEvaluate() throws FilterUnsupportedException, FilterIllegalMemberException {
    RowImpl rowImpl = new RowImpl();
    rowImpl.setValues(new Boolean[] { false });
    final ExpressionResult expressionResult = new ExpressionResult(DataType.BOOLEAN, "test");
    new MockUp<ColumnExpression>() {

        @Mock
        public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException, FilterIllegalMemberException {
            return expressionResult;
        }
    };
    ExpressionResult actualValue = andExpression.evaluate(rowImpl);
    assertTrue(actualValue instanceof ExpressionResult);
}
Also used : RowImpl(org.apache.carbondata.core.scan.filter.intf.RowImpl) ExpressionResult(org.apache.carbondata.core.scan.expression.ExpressionResult) RowIntf(org.apache.carbondata.core.scan.filter.intf.RowIntf) MockUp(mockit.MockUp) Test(org.junit.Test)

Example 2 with RowIntf

use of org.apache.carbondata.core.scan.filter.intf.RowIntf in project carbondata by apache.

the class AndExpressionTest method testEvaluateForDefault.

@Test(expected = Exception.class)
public void testEvaluateForDefault() throws FilterUnsupportedException, FilterIllegalMemberException {
    RowImpl rowImpl = new RowImpl();
    rowImpl.setValues(new Boolean[] { true });
    final ExpressionResult expressionResult = new ExpressionResult(DataType.STRING, "test");
    new MockUp<ColumnExpression>() {

        @Mock
        public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException, FilterIllegalMemberException {
            return expressionResult;
        }
    };
    andExpression.evaluate(rowImpl);
}
Also used : RowImpl(org.apache.carbondata.core.scan.filter.intf.RowImpl) ExpressionResult(org.apache.carbondata.core.scan.expression.ExpressionResult) RowIntf(org.apache.carbondata.core.scan.filter.intf.RowIntf) MockUp(mockit.MockUp) Test(org.junit.Test)

Example 3 with RowIntf

use of org.apache.carbondata.core.scan.filter.intf.RowIntf in project carbondata by apache.

the class OrExpressionTest method testEvaluate.

@Test
public void testEvaluate() throws FilterIllegalMemberException, FilterUnsupportedException {
    RowImpl rowImpl = new RowImpl();
    rowImpl.setValues(new Boolean[] { false });
    final ExpressionResult expressionResult = new ExpressionResult(DataType.BOOLEAN, "test");
    new MockUp<ColumnExpression>() {

        @Mock
        public ExpressionResult evaluate(RowIntf value) {
            return expressionResult;
        }
    };
    assertTrue(orExpression.evaluate(rowImpl) instanceof ExpressionResult);
}
Also used : RowImpl(org.apache.carbondata.core.scan.filter.intf.RowImpl) ExpressionResult(org.apache.carbondata.core.scan.expression.ExpressionResult) RowIntf(org.apache.carbondata.core.scan.filter.intf.RowIntf) MockUp(mockit.MockUp) Test(org.junit.Test)

Example 4 with RowIntf

use of org.apache.carbondata.core.scan.filter.intf.RowIntf in project carbondata by apache.

the class OrExpressionTest method testEvaluateForDefault.

@Test(expected = Exception.class)
public void testEvaluateForDefault() throws FilterUnsupportedException, FilterIllegalMemberException {
    RowImpl rowImpl = new RowImpl();
    rowImpl.setValues(new Boolean[] { true });
    final ExpressionResult expressionResult = new ExpressionResult(DataType.STRING, "test");
    new MockUp<ColumnExpression>() {

        @Mock
        public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException, FilterIllegalMemberException {
            return expressionResult;
        }
    };
    orExpression.evaluate(rowImpl);
}
Also used : RowImpl(org.apache.carbondata.core.scan.filter.intf.RowImpl) ExpressionResult(org.apache.carbondata.core.scan.expression.ExpressionResult) RowIntf(org.apache.carbondata.core.scan.filter.intf.RowIntf) MockUp(mockit.MockUp) Test(org.junit.Test)

Example 5 with RowIntf

use of org.apache.carbondata.core.scan.filter.intf.RowIntf in project carbondata by apache.

the class FilterUtil method getFilterListForAllMembersRS.

/**
   * This method will get the member based on filter expression evaluation from the
   * forward dictionary cache, this method will be basically used in restructure.
   *
   * @param expression
   * @param columnExpression
   * @param defaultValues
   * @param defaultSurrogate
   * @param isIncludeFilter
   * @return
   * @throws FilterUnsupportedException
   */
public static DimColumnFilterInfo getFilterListForAllMembersRS(Expression expression, ColumnExpression columnExpression, String defaultValues, int defaultSurrogate, boolean isIncludeFilter) throws FilterUnsupportedException {
    List<Integer> filterValuesList = new ArrayList<Integer>(20);
    List<String> evaluateResultListFinal = new ArrayList<String>(20);
    DimColumnFilterInfo columnFilterInfo = null;
    // KeyGeneratorFactory.getKeyGenerator(new int[] { defaultSurrogate });
    try {
        RowIntf row = new RowImpl();
        if (defaultValues.equals(CarbonCommonConstants.MEMBER_DEFAULT_VAL)) {
            defaultValues = null;
        }
        row.setValues(new Object[] { DataTypeUtil.getDataBasedOnDataType(defaultValues, columnExpression.getCarbonColumn().getDataType()) });
        Boolean rslt = expression.evaluate(row).getBoolean();
        if (null != rslt && rslt == isIncludeFilter) {
            if (null == defaultValues) {
                evaluateResultListFinal.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL);
            } else {
                evaluateResultListFinal.add(defaultValues);
            }
        }
    } catch (FilterIllegalMemberException e) {
        LOGGER.audit(e.getMessage());
    }
    if (null == defaultValues) {
        defaultValues = CarbonCommonConstants.MEMBER_DEFAULT_VAL;
    }
    columnFilterInfo = new DimColumnFilterInfo();
    for (int i = 0; i < evaluateResultListFinal.size(); i++) {
        if (evaluateResultListFinal.get(i).equals(defaultValues)) {
            filterValuesList.add(defaultSurrogate);
            break;
        }
    }
    columnFilterInfo.setFilterList(filterValuesList);
    return columnFilterInfo;
}
Also used : RowImpl(org.apache.carbondata.core.scan.filter.intf.RowImpl) ArrayList(java.util.ArrayList) RowIntf(org.apache.carbondata.core.scan.filter.intf.RowIntf) FilterIllegalMemberException(org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException)

Aggregations

RowImpl (org.apache.carbondata.core.scan.filter.intf.RowImpl)7 RowIntf (org.apache.carbondata.core.scan.filter.intf.RowIntf)7 MockUp (mockit.MockUp)4 ExpressionResult (org.apache.carbondata.core.scan.expression.ExpressionResult)4 Test (org.junit.Test)4 FilterIllegalMemberException (org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException)3 ArrayList (java.util.ArrayList)2 BitSet (java.util.BitSet)1 Dictionary (org.apache.carbondata.core.cache.dictionary.Dictionary)1 DictionaryChunksWrapper (org.apache.carbondata.core.cache.dictionary.DictionaryChunksWrapper)1 ForwardDictionary (org.apache.carbondata.core.cache.dictionary.ForwardDictionary)1 BitSetGroup (org.apache.carbondata.core.util.BitSetGroup)1