carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chenliang...@apache.org
Subject [46/50] [abbrv] incubator-carbondata git commit: Merge remote-tracking branch 'carbon_master/master' into apache/master
Date Thu, 30 Jun 2016 17:42:33 GMT
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/expression/conditional/GreaterThanExpression.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/expression/conditional/GreaterThanExpression.java
index 5c3bd56,0000000..59ff84f
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/expression/conditional/GreaterThanExpression.java
+++ b/core/src/main/java/org/carbondata/scan/expression/conditional/GreaterThanExpression.java
@@@ -1,92 -1,0 +1,93 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + *    http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +
 +package org.carbondata.scan.expression.conditional;
 +
 +import org.carbondata.scan.expression.DataType;
 +import org.carbondata.scan.expression.Expression;
 +import org.carbondata.scan.expression.ExpressionResult;
++import org.carbondata.scan.expression.exception.FilterIllegalMemberException;
 +import org.carbondata.scan.expression.exception.FilterUnsupportedException;
 +import org.carbondata.scan.filter.intf.ExpressionType;
 +import org.carbondata.scan.filter.intf.RowIntf;
 +
 +
 +public class GreaterThanExpression extends BinaryConditionalExpression {
 +  private static final long serialVersionUID = -5319109756575539219L;
 +
 +  public GreaterThanExpression(Expression left, Expression right) {
 +    super(left, right);
-     // TODO Auto-generated constructor stub
 +  }
 +
-   @Override public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException {
++  @Override public ExpressionResult evaluate(RowIntf value)
++      throws FilterUnsupportedException, FilterIllegalMemberException {
 +    ExpressionResult exprLeftRes = left.evaluate(value);
 +    ExpressionResult exprRightRes = right.evaluate(value);
 +    ExpressionResult val1 = exprLeftRes;
 +    if (exprLeftRes.isNull() || exprRightRes.isNull()) {
 +      exprLeftRes.set(DataType.BooleanType, false);
 +      return exprLeftRes;
 +    }
 +    if (exprLeftRes.getDataType() != exprRightRes.getDataType()) {
 +      if (exprLeftRes.getDataType().getPresedenceOrder() < exprRightRes.getDataType()
 +          .getPresedenceOrder()) {
 +        val1 = exprRightRes;
 +      }
 +
 +    }
 +    boolean result = false;
 +    switch (val1.getDataType()) {
 +      case StringType:
 +        result = exprLeftRes.getString().compareTo(exprRightRes.getString()) > 0;
 +        break;
 +      case DoubleType:
 +        result = exprLeftRes.getDouble() > (exprRightRes.getDouble());
 +        break;
 +      case ShortType:
 +        result = exprLeftRes.getShort() > (exprRightRes.getShort());
 +        break;
 +      case IntegerType:
 +        result = exprLeftRes.getInt() > (exprRightRes.getInt());
 +        break;
 +      case TimestampType:
 +        result = exprLeftRes.getTime() > (exprRightRes.getTime());
 +        break;
 +      case LongType:
 +        result = exprLeftRes.getLong() > (exprRightRes.getLong());
 +        break;
 +      case DecimalType:
 +        result = exprLeftRes.getDecimal().compareTo(exprRightRes.getDecimal()) > 0;
 +        break;
 +      default:
 +        throw new FilterUnsupportedException(
 +            "DataType: " + val1.getDataType() + " not supported for the filter expression");
 +    }
 +    val1.set(DataType.BooleanType, result);
 +    return val1;
 +  }
 +
 +  @Override public ExpressionType getFilterExpressionType() {
 +    return ExpressionType.GREATERTHAN;
 +  }
 +
 +  @Override public String getString() {
 +    return "GreaterThan(" + left.getString() + ',' + right.getString() + ')';
 +  }
 +
 +}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/expression/conditional/InExpression.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/expression/conditional/InExpression.java
index ddb35af,0000000..06e6ec6
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/expression/conditional/InExpression.java
+++ b/core/src/main/java/org/carbondata/scan/expression/conditional/InExpression.java
@@@ -1,102 -1,0 +1,102 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + *    http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +
 +package org.carbondata.scan.expression.conditional;
 +
 +import java.util.HashSet;
 +import java.util.Set;
 +
 +import org.carbondata.scan.expression.DataType;
 +import org.carbondata.scan.expression.Expression;
 +import org.carbondata.scan.expression.ExpressionResult;
++import org.carbondata.scan.expression.exception.FilterIllegalMemberException;
 +import org.carbondata.scan.expression.exception.FilterUnsupportedException;
 +import org.carbondata.scan.filter.intf.ExpressionType;
 +import org.carbondata.scan.filter.intf.RowIntf;
 +
 +public class InExpression extends BinaryConditionalExpression {
 +  private static final long serialVersionUID = -3149927446694175489L;
 +
 +  protected transient Set<ExpressionResult> setOfExprResult;
 +
 +  public InExpression(Expression left, Expression right) {
 +    super(left, right);
 +  }
 +
-   @Override public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException {
++  @Override public ExpressionResult evaluate(RowIntf value)
++      throws FilterUnsupportedException, FilterIllegalMemberException {
 +    ExpressionResult leftRsult = left.evaluate(value);
 +
 +    if (setOfExprResult == null) {
 +      ExpressionResult rightRsult = right.evaluate(value);
 +      ExpressionResult val = null;
 +      setOfExprResult = new HashSet<ExpressionResult>(10);
 +      for (ExpressionResult expressionResVal : rightRsult.getList()) {
 +
 +        if (leftRsult.getDataType().name().equals(expressionResVal.getDataType().name())) {
 +          if (expressionResVal.getDataType().getPresedenceOrder() < leftRsult.getDataType()
 +              .getPresedenceOrder()) {
 +            val = leftRsult;
 +          } else {
 +            val = expressionResVal;
 +          }
- 
 +          switch (val.getDataType()) {
 +            case StringType:
 +              val = new ExpressionResult(val.getDataType(), expressionResVal.getString());
 +              break;
 +            case ShortType:
 +              val = new ExpressionResult(val.getDataType(), expressionResVal.getShort());
 +              break;
 +            case IntegerType:
 +              val = new ExpressionResult(val.getDataType(), expressionResVal.getInt());
 +              break;
 +            case DoubleType:
 +              val = new ExpressionResult(val.getDataType(), expressionResVal.getDouble());
 +              break;
 +            case TimestampType:
 +              val = new ExpressionResult(val.getDataType(), expressionResVal.getTime());
 +              break;
 +            case LongType:
 +              val = new ExpressionResult(val.getDataType(), expressionResVal.getLong());
 +              break;
 +            case DecimalType:
 +              val = new ExpressionResult(val.getDataType(), expressionResVal.getDecimal());
 +              break;
 +            default:
 +              throw new FilterUnsupportedException(
 +                  "DataType: " + val.getDataType() + " not supported for the filter expression");
 +          }
- 
 +        }
 +        setOfExprResult.add(val);
 +
 +      }
 +    }
 +    leftRsult.set(DataType.BooleanType, setOfExprResult.contains(leftRsult));
 +    return leftRsult;
 +  }
 +
 +  @Override public ExpressionType getFilterExpressionType() {
 +    return ExpressionType.IN;
 +  }
 +
 +  @Override public String getString() {
 +    return "IN(" + left.getString() + ',' + right.getString() + ')';
 +  }
 +
 +}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/expression/conditional/LessThanEqualToExpression.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/expression/conditional/LessThanEqualToExpression.java
index c8aa6a7,0000000..54e7dd4
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/expression/conditional/LessThanEqualToExpression.java
+++ b/core/src/main/java/org/carbondata/scan/expression/conditional/LessThanEqualToExpression.java
@@@ -1,91 -1,0 +1,92 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + *    http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +
 +package org.carbondata.scan.expression.conditional;
 +
 +import org.carbondata.scan.expression.DataType;
 +import org.carbondata.scan.expression.Expression;
 +import org.carbondata.scan.expression.ExpressionResult;
++import org.carbondata.scan.expression.exception.FilterIllegalMemberException;
 +import org.carbondata.scan.expression.exception.FilterUnsupportedException;
 +import org.carbondata.scan.filter.intf.ExpressionType;
 +import org.carbondata.scan.filter.intf.RowIntf;
 +
 +public class LessThanEqualToExpression extends BinaryConditionalExpression {
 +  private static final long serialVersionUID = 1L;
 +
 +  public LessThanEqualToExpression(Expression left, Expression right) {
 +    super(left, right);
-     // TODO Auto-generated constructor stub
 +  }
 +
-   public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException {
++  public ExpressionResult evaluate(RowIntf value)
++      throws FilterUnsupportedException, FilterIllegalMemberException {
 +    ExpressionResult elRes = left.evaluate(value);
 +    ExpressionResult erRes = right.evaluate(value);
 +    ExpressionResult exprResValue1 = elRes;
 +    if (elRes.isNull() || erRes.isNull()) {
 +      elRes.set(DataType.BooleanType, false);
 +      return elRes;
 +    }
 +    if (elRes.getDataType() != erRes.getDataType()) {
 +      if (elRes.getDataType().getPresedenceOrder() < erRes.getDataType().getPresedenceOrder()) {
 +        exprResValue1 = erRes;
 +      }
 +
 +    }
 +    boolean result = false;
 +    switch (exprResValue1.getDataType()) {
 +      case StringType:
 +        result = elRes.getString().compareTo(erRes.getString()) <= 0;
 +        break;
 +      case ShortType:
 +        result = elRes.getShort() <= (erRes.getShort());
 +        break;
 +      case IntegerType:
 +        result = elRes.getInt() <= (erRes.getInt());
 +        break;
 +      case DoubleType:
 +        result = elRes.getDouble() <= (erRes.getDouble());
 +        break;
 +      case TimestampType:
 +        result = elRes.getTime() <= (erRes.getTime());
 +        break;
 +      case LongType:
 +        result = elRes.getLong() <= (erRes.getLong());
 +        break;
 +      case DecimalType:
 +        result = elRes.getDecimal().compareTo(erRes.getDecimal()) <= 0;
 +        break;
 +      default:
 +        throw new FilterUnsupportedException("DataType: " + exprResValue1.getDataType()
 +            + " not supported for the filter expression");
 +    }
 +    exprResValue1.set(DataType.BooleanType, result);
 +    return exprResValue1;
 +  }
 +
 +  @Override public ExpressionType getFilterExpressionType() {
 +    // TODO Auto-generated method stub
 +    return ExpressionType.LESSTHAN_EQUALTO;
 +  }
 +
 +  @Override public String getString() {
 +    return "LessThanEqualTo(" + left.getString() + ',' + right.getString() + ')';
 +  }
 +
 +}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/expression/conditional/LessThanExpression.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/expression/conditional/LessThanExpression.java
index 7e6580a,0000000..52ca777
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/expression/conditional/LessThanExpression.java
+++ b/core/src/main/java/org/carbondata/scan/expression/conditional/LessThanExpression.java
@@@ -1,93 -1,0 +1,95 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + *    http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +
 +package org.carbondata.scan.expression.conditional;
 +
 +import org.carbondata.scan.expression.DataType;
 +import org.carbondata.scan.expression.Expression;
 +import org.carbondata.scan.expression.ExpressionResult;
++import org.carbondata.scan.expression.exception.FilterIllegalMemberException;
 +import org.carbondata.scan.expression.exception.FilterUnsupportedException;
 +import org.carbondata.scan.filter.intf.ExpressionType;
 +import org.carbondata.scan.filter.intf.RowIntf;
 +
 +public class LessThanExpression extends BinaryConditionalExpression {
 +
 +  private static final long serialVersionUID = 6343040416663699924L;
 +
 +  public LessThanExpression(Expression left, Expression right) {
 +    super(left, right);
 +  }
 +
-   public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException {
++  public ExpressionResult evaluate(RowIntf value)
++      throws FilterUnsupportedException, FilterIllegalMemberException {
 +    ExpressionResult erRes = right.evaluate(value);
 +    ExpressionResult elRes = left.evaluate(value);
 +
 +    ExpressionResult val1 = elRes;
 +
 +    boolean result = false;
 +
 +    if (elRes.isNull() || erRes.isNull()) {
 +      elRes.set(DataType.BooleanType, false);
 +      return elRes;
 +    }
 +    if (elRes.getDataType() != erRes.getDataType()) {
 +      if (elRes.getDataType().getPresedenceOrder() < erRes.getDataType().getPresedenceOrder()) {
 +        val1 = erRes;
 +      }
 +
 +    }
 +    switch (val1.getDataType()) {
 +      case StringType:
 +        result = elRes.getString().compareTo(erRes.getString()) < 0;
 +        break;
 +      case ShortType:
 +        result = elRes.getShort() < (erRes.getShort());
 +        break;
 +      case IntegerType:
 +        result = elRes.getInt() < (erRes.getInt());
 +        break;
 +      case DoubleType:
 +        result = elRes.getDouble() < (erRes.getDouble());
 +        break;
 +      case TimestampType:
 +        result = elRes.getTime() < (erRes.getTime());
 +        break;
 +      case LongType:
 +        result = elRes.getLong() < (erRes.getLong());
 +        break;
 +      case DecimalType:
 +        result = elRes.getDecimal().compareTo(erRes.getDecimal()) < 0;
 +        break;
 +      default:
 +        throw new FilterUnsupportedException(
 +            "DataType: " + val1.getDataType() + " not supported for the filter expression");
 +    }
 +    val1.set(DataType.BooleanType, result);
 +    return val1;
 +  }
 +
 +  @Override public ExpressionType getFilterExpressionType() {
 +    return ExpressionType.LESSTHAN;
 +  }
 +
 +  @Override public String getString() {
 +    return "LessThan(" + left.getString() + ',' + right.getString() + ')';
 +  }
 +
 +}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/expression/conditional/ListExpression.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/expression/conditional/ListExpression.java
index b252793,0000000..b04b2b1
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/expression/conditional/ListExpression.java
+++ b/core/src/main/java/org/carbondata/scan/expression/conditional/ListExpression.java
@@@ -1,57 -1,0 +1,62 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + *    http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +
 +package org.carbondata.scan.expression.conditional;
 +
 +import java.util.ArrayList;
 +import java.util.List;
 +
 +import org.carbondata.scan.expression.Expression;
 +import org.carbondata.scan.expression.ExpressionResult;
++import org.carbondata.scan.expression.exception.FilterIllegalMemberException;
 +import org.carbondata.scan.expression.exception.FilterUnsupportedException;
 +import org.carbondata.scan.filter.intf.ExpressionType;
 +import org.carbondata.scan.filter.intf.RowIntf;
 +
 +public class ListExpression extends Expression {
 +  private static final long serialVersionUID = 1L;
 +
 +  public ListExpression(List<Expression> children) {
 +    this.children = children;
 +  }
 +
 +  @Override public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException {
 +    List<ExpressionResult> listOfExprRes = new ArrayList<ExpressionResult>(10);
 +
 +    for (Expression expr : children) {
-       listOfExprRes.add(expr.evaluate(value));
++      try {
++        listOfExprRes.add(expr.evaluate(value));
++      } catch (FilterIllegalMemberException e) {
++        continue;
++      }
 +    }
 +    return new ExpressionResult(listOfExprRes);
 +  }
 +
 +  @Override public ExpressionType getFilterExpressionType() {
 +    // TODO Auto-generated method stub
 +    return ExpressionType.LIST;
 +  }
 +
 +  @Override public String getString() {
 +    // TODO Auto-generated method stub
 +    return null;
 +  }
 +
 +}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/expression/conditional/NotEqualsExpression.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/expression/conditional/NotEqualsExpression.java
index 4f31c07,0000000..4f9a3d1
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/expression/conditional/NotEqualsExpression.java
+++ b/core/src/main/java/org/carbondata/scan/expression/conditional/NotEqualsExpression.java
@@@ -1,96 -1,0 +1,98 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + *    http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +
 +package org.carbondata.scan.expression.conditional;
 +
 +import org.carbondata.scan.expression.DataType;
 +import org.carbondata.scan.expression.Expression;
 +import org.carbondata.scan.expression.ExpressionResult;
++import org.carbondata.scan.expression.exception.FilterIllegalMemberException;
 +import org.carbondata.scan.expression.exception.FilterUnsupportedException;
 +import org.carbondata.scan.filter.intf.ExpressionType;
 +import org.carbondata.scan.filter.intf.RowIntf;
 +
 +public class NotEqualsExpression extends BinaryConditionalExpression {
 +
 +  private static final long serialVersionUID = 8684006025540863973L;
 +
 +  public NotEqualsExpression(Expression left, Expression right) {
 +    super(left, right);
 +  }
 +
-   @Override public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException {
++  @Override public ExpressionResult evaluate(RowIntf value)
++      throws FilterUnsupportedException, FilterIllegalMemberException {
 +    ExpressionResult elRes = left.evaluate(value);
 +    ExpressionResult erRes = right.evaluate(value);
 +
 +    boolean result = false;
 +    ExpressionResult val1 = elRes;
 +    ExpressionResult val2 = erRes;
 +
 +    if (elRes.isNull() || erRes.isNull()) {
 +      result = elRes.isNull() != erRes.isNull();
 +      val1.set(DataType.BooleanType, result);
 +      return val1;
 +    }
 +
 +    //default implementation if the data types are different for the resultsets
 +    if (elRes.getDataType() != erRes.getDataType()) {
 +      //            result = elRes.getString().equals(erRes.getString());
 +      if (elRes.getDataType().getPresedenceOrder() < erRes.getDataType().getPresedenceOrder()) {
 +        val1 = erRes;
 +        val2 = elRes;
 +      }
 +    }
 +    switch (val1.getDataType()) {
 +      case StringType:
 +        result = !val1.getString().equals(val2.getString());
 +        break;
 +      case ShortType:
 +        result = val1.getShort().shortValue() != val2.getShort().shortValue();
 +        break;
 +      case IntegerType:
 +        result = val1.getInt().intValue() != val2.getInt().intValue();
 +        break;
 +      case DoubleType:
 +        result = val1.getDouble().doubleValue() != val2.getDouble().doubleValue();
 +        break;
 +      case TimestampType:
 +        result = val1.getTime().longValue() != val2.getTime().longValue();
 +        break;
 +      case LongType:
 +        result = elRes.getLong().longValue() != (erRes.getLong()).longValue();
 +        break;
 +      case DecimalType:
 +        result = elRes.getDecimal().compareTo(erRes.getDecimal()) != 0;
 +        break;
 +      default:
 +        throw new FilterUnsupportedException(
 +            "DataType: " + val1.getDataType() + " not supported for the filter expression");
 +    }
 +    val1.set(DataType.BooleanType, result);
 +    return val1;
 +  }
 +
 +  @Override public ExpressionType getFilterExpressionType() {
 +    return ExpressionType.NOT_EQUALS;
 +  }
 +
 +  @Override public String getString() {
 +    return "NotEquals(" + left.getString() + ',' + right.getString() + ')';
 +  }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/expression/conditional/NotInExpression.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/expression/conditional/NotInExpression.java
index caa722a,0000000..eb9e6f6
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/expression/conditional/NotInExpression.java
+++ b/core/src/main/java/org/carbondata/scan/expression/conditional/NotInExpression.java
@@@ -1,103 -1,0 +1,103 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + *    http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +
 +package org.carbondata.scan.expression.conditional;
 +
 +import java.util.HashSet;
 +import java.util.Set;
 +
 +import org.carbondata.scan.expression.DataType;
 +import org.carbondata.scan.expression.Expression;
 +import org.carbondata.scan.expression.ExpressionResult;
++import org.carbondata.scan.expression.exception.FilterIllegalMemberException;
 +import org.carbondata.scan.expression.exception.FilterUnsupportedException;
 +import org.carbondata.scan.filter.intf.ExpressionType;
 +import org.carbondata.scan.filter.intf.RowIntf;
 +
 +public class NotInExpression extends BinaryConditionalExpression {
 +  private static final long serialVersionUID = -6835841923752118034L;
 +  protected transient Set<ExpressionResult> setOfExprResult;
 +
 +  public NotInExpression(Expression left, Expression right) {
 +    super(left, right);
 +  }
 +
-   @Override public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException {
++  @Override public ExpressionResult evaluate(RowIntf value)
++      throws FilterUnsupportedException, FilterIllegalMemberException {
 +    ExpressionResult leftRsult = left.evaluate(value);
 +
 +    if (setOfExprResult == null) {
 +      ExpressionResult val = null;
 +
 +      ExpressionResult rightRsult = right.evaluate(value);
 +      setOfExprResult = new HashSet<ExpressionResult>(10);
 +      for (ExpressionResult exprResVal : rightRsult.getList()) {
 +
 +        if (leftRsult.getDataType().name().equals(exprResVal.getDataType().name())) {
 +          if (exprResVal.getDataType().getPresedenceOrder() < leftRsult.getDataType()
 +              .getPresedenceOrder()) {
 +            val = leftRsult;
 +          } else {
 +            val = exprResVal;
 +          }
- 
 +          switch (val.getDataType()) {
 +            case StringType:
 +              val = new ExpressionResult(val.getDataType(), exprResVal.getString());
 +              break;
 +            case ShortType:
 +              val = new ExpressionResult(val.getDataType(), exprResVal.getShort());
 +              break;
 +            case IntegerType:
 +              val = new ExpressionResult(val.getDataType(), exprResVal.getInt());
 +              break;
 +            case DoubleType:
 +              val = new ExpressionResult(val.getDataType(), exprResVal.getDouble());
 +              break;
 +            case TimestampType:
 +              val = new ExpressionResult(val.getDataType(), exprResVal.getTime());
 +              break;
 +            case LongType:
 +              val = new ExpressionResult(val.getDataType(), exprResVal.getLong());
 +              break;
 +            case DecimalType:
 +              val = new ExpressionResult(val.getDataType(), exprResVal.getDecimal());
 +              break;
 +            default:
 +              throw new FilterUnsupportedException(
 +                  "DataType: " + val.getDataType() + " not supported for the filter expression");
 +          }
- 
 +        }
 +        setOfExprResult.add(val);
 +
 +      }
 +    }
 +    leftRsult.set(DataType.BooleanType, !setOfExprResult.contains(leftRsult));
 +
 +    return leftRsult;
 +  }
 +
 +  @Override public ExpressionType getFilterExpressionType() {
 +    return ExpressionType.NOT_IN;
 +  }
 +
 +  @Override public String getString() {
 +    return "NOT IN(" + left.getString() + ',' + right.getString() + ')';
 +  }
 +
 +}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/expression/exception/FilterIllegalMemberException.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/expression/exception/FilterIllegalMemberException.java
index 0000000,0000000..7130113
new file mode 100644
--- /dev/null
+++ b/core/src/main/java/org/carbondata/scan/expression/exception/FilterIllegalMemberException.java
@@@ -1,0 -1,0 +1,98 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements.  See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership.  The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License.  You may obtain a copy of the License at
++ *
++ *    http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing,
++ * software distributed under the License is distributed on an
++ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
++ * KIND, either express or implied.  See the License for the
++ * specific language governing permissions and limitations
++ * under the License.
++ */
++
++package org.carbondata.scan.expression.exception;
++
++import java.util.Locale;
++
++/**
++ * FilterIllegalMemberException class representing exception which can cause while evaluating
++ * filter members needs to be gracefully handled without propagating to outer layer so that
++ * the execution should not get interrupted.
++ */
++public class FilterIllegalMemberException extends Exception {
++
++  /**
++   * default serial version ID.
++   */
++  private static final long serialVersionUID = 1L;
++
++  /**
++   * The Error message.
++   */
++  private String msg = "";
++
++  /**
++   * Constructor
++   *
++   * @param errorCode The error code for this exception.
++   * @param msg       The error message for this exception.
++   */
++  public FilterIllegalMemberException(String msg) {
++    super(msg);
++    this.msg = msg;
++  }
++
++  /**
++   * Constructor
++   *
++   * @param errorCode The error code for this exception.
++   * @param msg       The error message for this exception.
++   */
++  public FilterIllegalMemberException(String msg, Throwable t) {
++    super(msg, t);
++    this.msg = msg;
++  }
++
++  /**
++   * Constructor
++   *
++   * @param errorCode The error code for this exception.
++   * @param msg       The error message for this exception.
++   */
++  public FilterIllegalMemberException(Throwable t) {
++    super(t);
++  }
++
++  /**
++   * This method is used to get the localized message.
++   *
++   * @param locale - A Locale object represents a specific geographical,
++   *               political, or cultural region.
++   * @return - Localized error message.
++   */
++  public String getLocalizedMessage(Locale locale) {
++    return "";
++  }
++
++  /**
++   * getLocalizedMessage
++   */
++  @Override public String getLocalizedMessage() {
++    return super.getLocalizedMessage();
++  }
++
++  /**
++   * getMessage
++   */
++  public String getMessage() {
++    return this.msg;
++  }
++
++}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/expression/exception/FilterUnsupportedException.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/expression/exception/FilterUnsupportedException.java
index c86a38d,0000000..dbc406e
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/expression/exception/FilterUnsupportedException.java
+++ b/core/src/main/java/org/carbondata/scan/expression/exception/FilterUnsupportedException.java
@@@ -1,93 -1,0 +1,92 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + *    http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +
 +package org.carbondata.scan.expression.exception;
 +
 +import java.util.Locale;
 +
 +public class FilterUnsupportedException extends Exception {
 +
 +  /**
 +   * default serial version ID.
 +   */
 +  private static final long serialVersionUID = 1L;
 +
 +  /**
 +   * The Error message.
 +   */
 +  private String msg = "";
 +
 +  /**
 +   * Constructor
 +   *
 +   * @param errorCode The error code for this exception.
 +   * @param msg       The error message for this exception.
 +   */
 +  public FilterUnsupportedException(String msg) {
 +    super(msg);
 +    this.msg = msg;
 +  }
 +
 +  /**
 +   * Constructor
 +   *
 +   * @param errorCode The error code for this exception.
 +   * @param msg       The error message for this exception.
 +   */
 +  public FilterUnsupportedException(String msg, Throwable t) {
 +    super(msg, t);
 +    this.msg = msg;
 +  }
 +
 +  /**
 +   * Constructor
 +   *
 +   * @param errorCode The error code for this exception.
 +   * @param msg       The error message for this exception.
 +   */
 +  public FilterUnsupportedException(Throwable t) {
 +    super(t);
 +  }
 +
 +  /**
 +   * This method is used to get the localized message.
 +   *
 +   * @param locale - A Locale object represents a specific geographical,
 +   *               political, or cultural region.
 +   * @return - Localized error message.
 +   */
 +  public String getLocalizedMessage(Locale locale) {
 +    return "";
 +  }
 +
 +  /**
 +   * getLocalizedMessage
 +   */
 +  @Override public String getLocalizedMessage() {
 +    return super.getLocalizedMessage();
 +  }
 +
 +  /**
 +   * getMessage
 +   */
 +  public String getMessage() {
 +    return this.msg;
 +  }
- 
 +}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/expression/logical/AndExpression.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/expression/logical/AndExpression.java
index b3f63bd,0000000..3a847bf
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/expression/logical/AndExpression.java
+++ b/core/src/main/java/org/carbondata/scan/expression/logical/AndExpression.java
@@@ -1,63 -1,0 +1,63 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + *    http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +
 +package org.carbondata.scan.expression.logical;
 +
 +import org.carbondata.scan.expression.DataType;
 +import org.carbondata.scan.expression.Expression;
 +import org.carbondata.scan.expression.ExpressionResult;
++import org.carbondata.scan.expression.exception.FilterIllegalMemberException;
 +import org.carbondata.scan.expression.exception.FilterUnsupportedException;
 +import org.carbondata.scan.filter.intf.ExpressionType;
 +import org.carbondata.scan.filter.intf.RowIntf;
 +
 +public class AndExpression extends BinaryLogicalExpression {
 +
 +  private static final long serialVersionUID = 1L;
 +
 +  public AndExpression(Expression left, Expression right) {
 +    super(left, right);
-     // TODO Auto-generated constructor stub
 +  }
 +
-   @Override public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException {
++  @Override public ExpressionResult evaluate(RowIntf value)
++      throws FilterUnsupportedException, FilterIllegalMemberException {
 +    ExpressionResult resultLeft = left.evaluate(value);
 +    ExpressionResult resultRight = right.evaluate(value);
 +    switch (resultLeft.getDataType()) {
 +      case BooleanType:
 +        resultLeft.set(DataType.BooleanType, (resultLeft.getBoolean() && resultRight.getBoolean()));
 +        break;
 +      default:
 +        throw new FilterUnsupportedException(
 +            "Incompatible datatype for applying AND Expression Filter");
 +    }
- 
 +    return resultLeft;
 +  }
 +
 +  @Override public ExpressionType getFilterExpressionType() {
 +    // TODO Auto-generated method stub
 +    return ExpressionType.AND;
 +  }
 +
 +  @Override public String getString() {
 +    // TODO Auto-generated method stub
 +    return "And(" + left.getString() + ',' + right.getString() + ')';
 +  }
 +
 +}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/expression/logical/NotExpression.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/expression/logical/NotExpression.java
index 239af8f,0000000..dba58aa
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/expression/logical/NotExpression.java
+++ b/core/src/main/java/org/carbondata/scan/expression/logical/NotExpression.java
@@@ -1,58 -1,0 +1,60 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + *    http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +
 +package org.carbondata.scan.expression.logical;
 +
 +import org.carbondata.scan.expression.DataType;
 +import org.carbondata.scan.expression.Expression;
 +import org.carbondata.scan.expression.ExpressionResult;
 +import org.carbondata.scan.expression.UnaryExpression;
++import org.carbondata.scan.expression.exception.FilterIllegalMemberException;
 +import org.carbondata.scan.expression.exception.FilterUnsupportedException;
 +import org.carbondata.scan.filter.intf.ExpressionType;
 +import org.carbondata.scan.filter.intf.RowIntf;
 +
 +public class NotExpression extends UnaryExpression {
 +  private static final long serialVersionUID = 1L;
 +
 +  public NotExpression(Expression child) {
 +    super(child);
 +  }
 +
-   @Override public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException {
++  @Override public ExpressionResult evaluate(RowIntf value)
++      throws FilterIllegalMemberException, FilterUnsupportedException {
 +    ExpressionResult expResult = child.evaluate(value);
 +    expResult.set(DataType.BooleanType, !(expResult.getBoolean()));
 +    switch (expResult.getDataType()) {
 +      case BooleanType:
 +        expResult.set(DataType.BooleanType, !(expResult.getBoolean()));
 +        break;
 +      default:
 +        throw new FilterUnsupportedException(
 +            "Incompatible datatype for applying NOT Expression Filter");
 +    }
 +    return expResult;
 +  }
 +
 +  @Override public ExpressionType getFilterExpressionType() {
 +    return ExpressionType.NOT;
 +  }
 +
 +  @Override public String getString() {
 +    return "Not(" + child.getString() + ')';
 +  }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/expression/logical/OrExpression.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/expression/logical/OrExpression.java
index 86d6c8d,0000000..43adbf4
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/expression/logical/OrExpression.java
+++ b/core/src/main/java/org/carbondata/scan/expression/logical/OrExpression.java
@@@ -1,60 -1,0 +1,62 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + *    http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +
 +package org.carbondata.scan.expression.logical;
 +
 +import org.carbondata.scan.expression.DataType;
 +import org.carbondata.scan.expression.Expression;
 +import org.carbondata.scan.expression.ExpressionResult;
++import org.carbondata.scan.expression.exception.FilterIllegalMemberException;
 +import org.carbondata.scan.expression.exception.FilterUnsupportedException;
 +import org.carbondata.scan.filter.intf.ExpressionType;
 +import org.carbondata.scan.filter.intf.RowIntf;
 +
 +public class OrExpression extends BinaryLogicalExpression {
 +
 +  private static final long serialVersionUID = 4220598043176438380L;
 +
 +  public OrExpression(Expression left, Expression right) {
 +    super(left, right);
 +  }
 +
-   @Override public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException {
++  @Override public ExpressionResult evaluate(RowIntf value)
++      throws FilterIllegalMemberException, FilterUnsupportedException {
 +    ExpressionResult resultLeft = left.evaluate(value);
 +    ExpressionResult resultRight = right.evaluate(value);
 +    switch (resultLeft.getDataType()) {
 +      case BooleanType:
 +        resultLeft.set(DataType.BooleanType, (resultLeft.getBoolean() || resultRight.getBoolean()));
 +        break;
 +      default:
 +        throw new FilterUnsupportedException(
 +            "Incompatible datatype for applying OR Expression Filter");
 +    }
 +
 +    return resultLeft;
 +  }
 +
 +  @Override public ExpressionType getFilterExpressionType() {
 +    return ExpressionType.OR;
 +  }
 +
 +  @Override public String getString() {
 +    return "Or(" + left.getString() + ',' + right.getString() + ')';
 +  }
 +
 +}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/filter/FilterExpressionProcessor.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/filter/FilterExpressionProcessor.java
index e5dd7b4,0000000..387b1cc
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/filter/FilterExpressionProcessor.java
+++ b/core/src/main/java/org/carbondata/scan/filter/FilterExpressionProcessor.java
@@@ -1,360 -1,0 +1,350 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + *    http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +package org.carbondata.scan.filter;
 +
 +import java.util.ArrayList;
 +import java.util.BitSet;
 +import java.util.List;
 +
 +import org.carbondata.common.logging.LogService;
 +import org.carbondata.common.logging.LogServiceFactory;
 +import org.carbondata.core.carbon.AbsoluteTableIdentifier;
 +import org.carbondata.core.carbon.datastore.DataRefNode;
 +import org.carbondata.core.carbon.datastore.DataRefNodeFinder;
 +import org.carbondata.core.carbon.datastore.IndexKey;
 +import org.carbondata.core.carbon.datastore.block.AbstractIndex;
 +import org.carbondata.core.carbon.datastore.block.SegmentProperties;
 +import org.carbondata.core.carbon.datastore.impl.btree.BTreeDataRefNodeFinder;
 +import org.carbondata.core.carbon.metadata.datatype.DataType;
 +import org.carbondata.core.carbon.metadata.encoder.Encoding;
 +import org.carbondata.core.keygenerator.KeyGenException;
 +import org.carbondata.scan.executor.exception.QueryExecutionException;
 +import org.carbondata.scan.expression.BinaryExpression;
 +import org.carbondata.scan.expression.Expression;
 +import org.carbondata.scan.expression.conditional.BinaryConditionalExpression;
 +import org.carbondata.scan.expression.conditional.ConditionalExpression;
 +import org.carbondata.scan.expression.exception.FilterUnsupportedException;
 +import org.carbondata.scan.expression.logical.BinaryLogicalExpression;
 +import org.carbondata.scan.filter.executer.FilterExecuter;
 +import org.carbondata.scan.filter.intf.ExpressionType;
 +import org.carbondata.scan.filter.resolver.ConditionalFilterResolverImpl;
 +import org.carbondata.scan.filter.resolver.FilterResolverIntf;
 +import org.carbondata.scan.filter.resolver.LogicalFilterResolverImpl;
 +import org.carbondata.scan.filter.resolver.RowLevelFilterResolverImpl;
 +import org.carbondata.scan.filter.resolver.RowLevelRangeFilterResolverImpl;
 +
 +public class FilterExpressionProcessor implements FilterProcessor {
 +
 +  private static final LogService LOGGER =
 +      LogServiceFactory.getLogService(FilterExpressionProcessor.class.getName());
 +
 +  /**
 +   * Implementation will provide the resolved form of filters based on the
 +   * filter expression tree which is been passed in Expression instance.
 +   *
 +   * @param expressionTree  , filter expression tree
 +   * @param tableIdentifier ,contains carbon store informations
 +   * @return a filter resolver tree
 +   * @throws QueryExecutionException
 +   * @throws FilterUnsupportedException
 +   */
 +  public FilterResolverIntf getFilterResolver(Expression expressionTree,
 +      AbsoluteTableIdentifier tableIdentifier) throws FilterUnsupportedException {
 +    if (null != expressionTree && null != tableIdentifier) {
 +      return getFilterResolvertree(expressionTree, tableIdentifier);
 +    }
 +    return null;
 +  }
 +
 +  /**
 +   * This API will scan the Segment level all btrees and selects the required
 +   * block reference  nodes inorder to push the same to executer for applying filters
 +   * on the respective data reference node.
 +   * Following Algorithm is followed in below API
 +   * Step:1 Get the start end key based on the filter tree resolver information
 +   * Step:2 Prepare the IndexKeys inorder to scan the tree and get the start and end reference
 +   * node(block)
 +   * Step:3 Once data reference node ranges retrieved traverse the node within this range
 +   * and select the node based on the block min and max value and the filter value.
 +   * Step:4 The selected blocks will be send to executers for applying the filters with the help
 +   * of Filter executers.
 +   *
 +   * @throws QueryExecutionException
 +   */
 +  public List<DataRefNode> getFilterredBlocks(DataRefNode btreeNode,
 +      FilterResolverIntf filterResolver, AbstractIndex tableSegment,
 +      AbsoluteTableIdentifier tableIdentifier) throws QueryExecutionException {
 +    // Need to get the current dimension tables
 +    List<DataRefNode> listOfDataBlocksToScan = new ArrayList<DataRefNode>();
 +    // getting the start and end index key based on filter for hitting the
 +    // selected block reference nodes based on filter resolver tree.
 +    LOGGER.info("preparing the start and end key for finding"
 +        + "start and end block as per filter resolver");
 +    List<IndexKey> listOfStartEndKeys = new ArrayList<IndexKey>(2);
 +    FilterUtil.traverseResolverTreeAndGetStartAndEndKey(tableSegment.getSegmentProperties(),
 +        tableIdentifier, filterResolver, listOfStartEndKeys);
 +    // reading the first value from list which has start key
 +    IndexKey searchStartKey = listOfStartEndKeys.get(0);
 +    // reading the last value from list which has end key
 +    IndexKey searchEndKey = listOfStartEndKeys.get(1);
 +    if (null == searchStartKey && null == searchEndKey) {
 +      try {
 +        // TODO need to handle for no dictionary dimensions
 +        searchStartKey =
 +            FilterUtil.prepareDefaultStartIndexKey(tableSegment.getSegmentProperties());
 +        // TODO need to handle for no dictionary dimensions
 +        searchEndKey = FilterUtil.prepareDefaultEndIndexKey(tableSegment.getSegmentProperties());
 +      } catch (KeyGenException e) {
 +        return listOfDataBlocksToScan;
 +      }
 +    }
 +
 +    LOGGER.info("Successfully retrieved the start and end key");
 +    long startTimeInMillis = System.currentTimeMillis();
 +    DataRefNodeFinder blockFinder = new BTreeDataRefNodeFinder(
 +        tableSegment.getSegmentProperties().getDimensionColumnsValueSize());
 +    DataRefNode startBlock = blockFinder.findFirstDataBlock(btreeNode, searchStartKey);
 +    DataRefNode endBlock = blockFinder.findLastDataBlock(btreeNode, searchEndKey);
 +    FilterExecuter filterExecuter =
-             FilterUtil.getFilterExecuterTree(filterResolver, tableSegment.getSegmentProperties());
++        FilterUtil.getFilterExecuterTree(filterResolver, tableSegment.getSegmentProperties());
 +    while (startBlock != endBlock) {
 +      addBlockBasedOnMinMaxValue(filterExecuter, listOfDataBlocksToScan, startBlock,
 +          tableSegment.getSegmentProperties());
 +      startBlock = startBlock.getNextDataRefNode();
 +    }
 +    addBlockBasedOnMinMaxValue(filterExecuter, listOfDataBlocksToScan, endBlock,
 +        tableSegment.getSegmentProperties());
 +    LOGGER.info("Total Time in retrieving the data reference node" + "after scanning the btree " + (
 +        System.currentTimeMillis() - startTimeInMillis)
 +        + " Total number of data reference node for executing filter(s) " + listOfDataBlocksToScan
 +        .size());
 +
 +    return listOfDataBlocksToScan;
 +  }
 +
 +  /**
 +   * Selects the blocks based on col max and min value.
 +   *
 +   * @param filterResolver
 +   * @param listOfDataBlocksToScan
 +   * @param dataRefNode
 +   * @param segmentProperties
 +   */
 +  private void addBlockBasedOnMinMaxValue(FilterExecuter filterExecuter,
 +      List<DataRefNode> listOfDataBlocksToScan, DataRefNode dataRefNode,
 +      SegmentProperties segmentProperties) {
 +
 +    BitSet bitSet = filterExecuter
 +        .isScanRequired(dataRefNode.getColumnsMaxValue(), dataRefNode.getColumnsMinValue());
 +    if (!bitSet.isEmpty()) {
 +      listOfDataBlocksToScan.add(dataRefNode);
 +
 +    }
 +  }
 +
 +  /**
 +   * API will return a filter resolver instance which will be used by
 +   * executers to evaluate or execute the filters.
 +   *
 +   * @param expressionTree , resolver tree which will hold the resolver tree based on
 +   *                       filter expression.
 +   * @return FilterResolverIntf type.
 +   * @throws QueryExecutionException
 +   * @throws FilterUnsupportedException
 +   */
 +  private FilterResolverIntf getFilterResolvertree(Expression expressionTree,
 +      AbsoluteTableIdentifier tableIdentifier) throws FilterUnsupportedException {
 +    FilterResolverIntf filterEvaluatorTree =
 +        createFilterResolverTree(expressionTree, tableIdentifier, null);
 +    traverseAndResolveTree(filterEvaluatorTree, tableIdentifier);
 +    return filterEvaluatorTree;
 +  }
 +
 +  /**
 +   * constructing the filter resolver tree based on filter expression.
 +   * this method will visit each node of the filter resolver and prepares
 +   * the surrogates of the filter members which are involved filter
 +   * expression.
 +   *
 +   * @param filterResolverTree
 +   * @param tableIdentifier
++   * @throws FilterUnsupportedException
 +   * @throws QueryExecutionException
 +   */
 +  private void traverseAndResolveTree(FilterResolverIntf filterResolverTree,
 +      AbsoluteTableIdentifier tableIdentifier) throws FilterUnsupportedException {
 +    if (null == filterResolverTree) {
 +      return;
 +    }
 +    traverseAndResolveTree(filterResolverTree.getLeft(), tableIdentifier);
 +
 +    filterResolverTree.resolve(tableIdentifier);
 +
 +    traverseAndResolveTree(filterResolverTree.getRight(), tableIdentifier);
 +  }
 +
 +  /**
 +   * Pattern used : Visitor Pattern
 +   * Method will create filter resolver tree based on the filter expression tree,
 +   * in this algorithm based on the expression instance the resolvers will created
 +   *
 +   * @param expressionTree
 +   * @param tableIdentifier
 +   * @return
 +   */
 +  private FilterResolverIntf createFilterResolverTree(Expression expressionTree,
 +      AbsoluteTableIdentifier tableIdentifier, Expression intermediateExpression) {
 +    ExpressionType filterExpressionType = expressionTree.getFilterExpressionType();
 +    BinaryExpression currentExpression = null;
 +    BinaryLogicalExpression logicalExpression = null;
 +    switch (filterExpressionType) {
 +      case OR:
 +        currentExpression = (BinaryExpression) expressionTree;
 +        return new LogicalFilterResolverImpl(
 +            createFilterResolverTree(currentExpression.getLeft(), tableIdentifier,
 +                currentExpression),
 +            createFilterResolverTree(currentExpression.getRight(), tableIdentifier,
 +                currentExpression), filterExpressionType);
 +      case AND:
 +        logicalExpression = (BinaryLogicalExpression) expressionTree;
 +        return new LogicalFilterResolverImpl(
 +            createFilterResolverTree(logicalExpression.getLeft(), tableIdentifier,
 +                currentExpression),
 +            createFilterResolverTree(logicalExpression.getRight(), tableIdentifier,
 +                currentExpression), filterExpressionType);
 +      case EQUALS:
 +      case IN:
 +        return getFilterResolverBasedOnExpressionType(ExpressionType.EQUALS, false, expressionTree,
 +            tableIdentifier, expressionTree);
 +      case GREATERTHAN:
 +      case GREATERTHAN_EQUALTO:
 +      case LESSTHAN:
 +      case LESSTHAN_EQUALTO:
 +        return getFilterResolverBasedOnExpressionType(ExpressionType.EQUALS, true, expressionTree,
 +            tableIdentifier, expressionTree);
 +
 +      case NOT_EQUALS:
 +      case NOT_IN:
 +        return getFilterResolverBasedOnExpressionType(ExpressionType.NOT_EQUALS, false,
 +            expressionTree, tableIdentifier, expressionTree);
 +
 +      default:
 +        return getFilterResolverBasedOnExpressionType(ExpressionType.UNKNOWN, false, expressionTree,
 +            tableIdentifier, expressionTree);
 +    }
 +  }
 +
 +  /**
 +   * Factory method which will return the resolver instance based on filter expression
 +   * expressions.
 +   */
 +  private FilterResolverIntf getFilterResolverBasedOnExpressionType(
 +      ExpressionType filterExpressionType, boolean isExpressionResolve, Expression expression,
 +      AbsoluteTableIdentifier tableIdentifier, Expression expressionTree) {
 +    BinaryConditionalExpression currentCondExpression = null;
 +    ConditionalExpression condExpression = null;
 +    switch (filterExpressionType) {
 +      case EQUALS:
 +        currentCondExpression = (BinaryConditionalExpression) expression;
 +        if (currentCondExpression.isSingleDimension()
 +            && currentCondExpression.getColumnList().get(0).getCarbonColumn().getDataType()
 +            != DataType.ARRAY
 +            && currentCondExpression.getColumnList().get(0).getCarbonColumn().getDataType()
 +            != DataType.STRUCT) {
 +          // getting new dim index.
 +          if (!currentCondExpression.getColumnList().get(0).getCarbonColumn()
 +              .hasEncoding(Encoding.DICTIONARY) || currentCondExpression.getColumnList().get(0)
 +              .getCarbonColumn().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
 +            if (FilterUtil.checkIfExpressionContainsColumn(currentCondExpression.getLeft())
 +                && FilterUtil.checkIfExpressionContainsColumn(currentCondExpression.getRight()) || (
 +                FilterUtil.checkIfExpressionContainsUnknownExp(currentCondExpression.getRight())
 +                    || FilterUtil
 +                    .checkIfExpressionContainsUnknownExp(currentCondExpression.getLeft()))) {
 +              return new RowLevelFilterResolverImpl(expression, isExpressionResolve, true,
 +                  tableIdentifier);
 +            }
 +            if (currentCondExpression.getFilterExpressionType() == ExpressionType.GREATERTHAN
 +                || currentCondExpression.getFilterExpressionType() == ExpressionType.LESSTHAN
 +                || currentCondExpression.getFilterExpressionType()
 +                == ExpressionType.GREATERTHAN_EQUALTO
 +                || currentCondExpression.getFilterExpressionType()
 +                == ExpressionType.LESSTHAN_EQUALTO) {
-               if (currentCondExpression.getColumnList().get(0).getCarbonColumn()
-                   .hasEncoding(Encoding.DIRECT_DICTIONARY)) {
-                 return new RowLevelFilterResolverImpl(expression, isExpressionResolve, true,
-                     tableIdentifier);
-               }
 +              return new RowLevelRangeFilterResolverImpl(expression, isExpressionResolve, true,
 +                  tableIdentifier);
 +            }
 +          }
 +          return new ConditionalFilterResolverImpl(expression, isExpressionResolve, true);
 +
 +        }
 +        break;
 +      case NOT_EQUALS:
 +        currentCondExpression = (BinaryConditionalExpression) expression;
 +        if (currentCondExpression.isSingleDimension()
 +            && currentCondExpression.getColumnList().get(0).getCarbonColumn().getDataType()
 +            != DataType.ARRAY
 +            && currentCondExpression.getColumnList().get(0).getCarbonColumn().getDataType()
 +            != DataType.STRUCT) {
 +          if (!currentCondExpression.getColumnList().get(0).getCarbonColumn()
-               .hasEncoding(Encoding.DICTIONARY)) {
++              .hasEncoding(Encoding.DICTIONARY) || currentCondExpression.getColumnList().get(0)
++              .getCarbonColumn().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
 +            if (FilterUtil.checkIfExpressionContainsColumn(currentCondExpression.getLeft())
-                 && FilterUtil.checkIfExpressionContainsColumn(currentCondExpression.getRight())
-                 || (FilterUtil
-                     .checkIfExpressionContainsUnknownExp(currentCondExpression.getRight())
-                 || FilterUtil
++                && FilterUtil.checkIfExpressionContainsColumn(currentCondExpression.getRight()) || (
++                FilterUtil.checkIfExpressionContainsUnknownExp(currentCondExpression.getRight())
++                    || FilterUtil
 +                    .checkIfExpressionContainsUnknownExp(currentCondExpression.getLeft()))) {
 +              return new RowLevelFilterResolverImpl(expression, isExpressionResolve, false,
 +                  tableIdentifier);
 +            }
 +            if (expressionTree.getFilterExpressionType() == ExpressionType.GREATERTHAN
 +                || expressionTree.getFilterExpressionType() == ExpressionType.LESSTHAN
 +                || expressionTree.getFilterExpressionType() == ExpressionType.GREATERTHAN_EQUALTO
 +                || expressionTree.getFilterExpressionType() == ExpressionType.LESSTHAN_EQUALTO) {
 +
 +              return new RowLevelRangeFilterResolverImpl(expression, isExpressionResolve, false,
 +                  tableIdentifier);
 +            }
 +
 +            return new ConditionalFilterResolverImpl(expression, isExpressionResolve, false);
 +          }
 +          return new ConditionalFilterResolverImpl(expression, isExpressionResolve, false);
 +        }
 +        break;
 +      default:
 +        condExpression = (ConditionalExpression) expression;
 +        if (condExpression.isSingleDimension()
 +            && condExpression.getColumnList().get(0).getCarbonColumn().getDataType()
 +            != DataType.ARRAY
 +            && condExpression.getColumnList().get(0).getCarbonColumn().getDataType()
 +            != DataType.STRUCT) {
 +          condExpression = (ConditionalExpression) expression;
-           if (condExpression.isSingleDimension()) {
-             if (!condExpression.getColumnList().get(0).getCarbonColumn()
-                 .hasEncoding(Encoding.DICTIONARY)) {
-               if (FilterUtil.checkIfExpressionContainsColumn(expression)) {
-                 return new RowLevelFilterResolverImpl(expression, isExpressionResolve, false,
-                     tableIdentifier);
-               } else if (expressionTree.getFilterExpressionType() == ExpressionType.UNKNOWN) {
-                 return new RowLevelFilterResolverImpl(expression, false, false, tableIdentifier);
-               }
- 
-               return new ConditionalFilterResolverImpl(expression, true, true);
-             }
++          if (condExpression.getColumnList().get(0).getCarbonColumn()
++              .hasEncoding(Encoding.DICTIONARY) && !condExpression.getColumnList().get(0)
++              .getCarbonColumn().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
++            return new ConditionalFilterResolverImpl(expression, true, true);
++          } else {
++            return new RowLevelFilterResolverImpl(expression, false, false, tableIdentifier);
 +          }
 +        } else {
 +          return new RowLevelFilterResolverImpl(expression, false, false, tableIdentifier);
 +        }
 +    }
 +    return new RowLevelFilterResolverImpl(expression, false, false, tableIdentifier);
 +  }
 +
 +}


Mime
View raw message