You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by jb...@apache.org on 2016/06/23 14:16:24 UTC
[36/56] [abbrv] incubator-carbondata git commit: Refactor
org.carbondata.query package (#692)
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/1c725f5b/core/src/main/java/org/carbondata/query/expression/ExpressionResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/ExpressionResult.java b/core/src/main/java/org/carbondata/query/expression/ExpressionResult.java
deleted file mode 100644
index 3c09c8f..0000000
--- a/core/src/main/java/org/carbondata/query/expression/ExpressionResult.java
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additiona l 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.query.expression;
-
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.carbondata.core.constants.CarbonCommonConstants;
-import org.carbondata.core.util.CarbonProperties;
-import org.carbondata.query.expression.exception.FilterUnsupportedException;
-
-public class ExpressionResult implements Comparable<ExpressionResult> {
-
- private static final long serialVersionUID = 1L;
- protected DataType dataType;
-
- protected Object value;
-
- private List<ExpressionResult> expressionResults;
-
- public ExpressionResult(DataType dataType, Object value) {
- this.dataType = dataType;
- this.value = value;
- }
-
- public ExpressionResult(List<ExpressionResult> expressionResults) {
- this.expressionResults = expressionResults;
- }
-
- public void set(DataType dataType, Object value) {
- this.dataType = dataType;
- this.value = value;
- this.expressionResults = null;
- }
-
- public DataType getDataType() {
- return dataType;
- }
-
- //CHECKSTYLE:OFF Approval No:Approval-V1R2C10_009
- public Integer getInt() throws FilterUnsupportedException {
- if (value == null) {
- return null;
- }
- try {
- switch (this.getDataType()) {
- case StringType:
- try {
- return Integer.parseInt(value.toString());
- } catch (NumberFormatException e) {
- throw new FilterUnsupportedException(e);
- }
-
- case IntegerType:
- case DoubleType:
-
- if (value instanceof Double) {
- return ((Double) value).intValue();
- }
- return (Integer) value;
-
- case TimestampType:
-
- if (value instanceof Timestamp) {
- return (int) (((Timestamp) value).getTime() % 1000);
- } else {
- return (Integer) value;
- }
-
- default:
- throw new FilterUnsupportedException(
- "Cannot convert" + this.getDataType().name() + " to integer type value");
- }
-
- } catch (ClassCastException e) {
- throw new FilterUnsupportedException(
- "Cannot convert" + this.getDataType().name() + " to Integer type value");
- }
- }
-
- public String getString() {
- if (value == null) {
- return null;
- }
- switch (this.getDataType()) {
- case TimestampType:
- SimpleDateFormat parser = new SimpleDateFormat(CarbonProperties.getInstance()
- .getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
- CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT));
- if (value instanceof Timestamp) {
- return parser.format((Timestamp) value);
- } else {
- return parser.format(new Timestamp((long) value / 1000));
- }
-
- default:
- return value.toString();
- }
- }
-
- public Double getDouble() throws FilterUnsupportedException {
- if (value == null) {
- return null;
- }
- try {
- switch (this.getDataType()) {
- case StringType:
- try {
- return Double.parseDouble(value.toString());
- } catch (NumberFormatException e) {
- throw new FilterUnsupportedException(e);
- }
-
- case IntegerType:
- return ((Integer) value).doubleValue();
- case LongType:
- return ((Long) value).doubleValue();
- case DoubleType:
- return (Double) value;
- case TimestampType:
- if (value instanceof Timestamp) {
- return (double) ((Timestamp) value).getTime() * 1000;
- } else {
- return (Double) (value);
- }
- default:
- throw new FilterUnsupportedException(
- "Cannot convert" + this.getDataType().name() + " to double type value");
- }
- } catch (ClassCastException e) {
- throw new FilterUnsupportedException(
- "Cannot convert" + this.getDataType().name() + " to Double type value");
- }
- }
- //CHECKSTYLE:ON
-
- public Long getLong() throws FilterUnsupportedException {
- if (value == null) {
- return null;
- }
- try {
- switch (this.getDataType()) {
- case StringType:
- try {
- return Long.parseLong(value.toString());
- } catch (NumberFormatException e) {
- throw new FilterUnsupportedException(e);
- }
-
- case IntegerType:
- return (Long) value;
- case LongType:
- return (Long) value;
- case DoubleType:
- return (Long) value;
- case TimestampType:
- if (value instanceof Timestamp) {
- return 1000 * ((Timestamp) value).getTime();
- } else {
- return (Long) value;
- }
- default:
- throw new FilterUnsupportedException(
- "Cannot convert" + this.getDataType().name() + " to Long type value");
- }
- } catch (ClassCastException e) {
- throw new FilterUnsupportedException(
- "Cannot convert" + this.getDataType().name() + " to Long type value");
- }
-
- }
-
- //Add to judge for BigDecimal
- public BigDecimal getDecimal() throws FilterUnsupportedException {
- if (value == null) {
- return null;
- }
- try {
- switch (this.getDataType()) {
- case StringType:
- try {
- return new BigDecimal(value.toString());
- } catch (NumberFormatException e) {
- throw new FilterUnsupportedException(e);
- }
-
- case IntegerType:
- return new BigDecimal((int) value);
- case LongType:
- return new BigDecimal((long) value);
- case DoubleType:
- return new BigDecimal((double) value);
- case DecimalType:
- return new BigDecimal(value.toString());
- case TimestampType:
- if (value instanceof Timestamp) {
- return new BigDecimal(1000 * ((Timestamp) value).getTime());
- } else {
- return new BigDecimal((long) value);
- }
- default:
- throw new FilterUnsupportedException(
- "Cannot convert" + this.getDataType().name() + " to Long type value");
- }
- } catch (ClassCastException e) {
- throw new FilterUnsupportedException(
- "Cannot convert" + this.getDataType().name() + " to Long type value");
- }
-
- }
-
- public Long getTime() throws FilterUnsupportedException {
- if (value == null) {
- return null;
- }
- try {
- switch (this.getDataType()) {
- case StringType:
- SimpleDateFormat parser = new SimpleDateFormat(CarbonProperties.getInstance()
- .getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
- CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT));
- Date dateToStr;
- try {
- dateToStr = parser.parse(value.toString());
- return dateToStr.getTime() * 1000;
- } catch (ParseException e) {
- throw new FilterUnsupportedException(
- "Cannot convert" + this.getDataType().name() + " to Time/Long type value");
- }
- case IntegerType:
- case LongType:
- return (Long) value;
- case DoubleType:
- return (Long) value;
- case TimestampType:
- if (value instanceof Timestamp) {
- return ((Timestamp) value).getTime() * 1000;
- } else {
- return (Long) value;
- }
- default:
- throw new FilterUnsupportedException(
- "Cannot convert" + this.getDataType().name() + " to Time/Long type value");
- }
- } catch (ClassCastException e) {
- throw new FilterUnsupportedException(
- "Cannot convert" + this.getDataType().name() + " to Time/Long type value");
- }
-
- }
-
- public Boolean getBoolean() throws FilterUnsupportedException {
- if (value == null) {
- return null;
- }
- try {
- switch (this.getDataType()) {
- case StringType:
- try {
- return Boolean.parseBoolean(value.toString());
- } catch (NumberFormatException e) {
- throw new FilterUnsupportedException(e);
- }
-
- case BooleanType:
- return Boolean.parseBoolean(value.toString());
-
- default:
- throw new FilterUnsupportedException(
- "Cannot convert" + this.getDataType().name() + " to boolean type value");
- }
- } catch (ClassCastException e) {
- throw new FilterUnsupportedException(
- "Cannot convert" + this.getDataType().name() + " to Boolean type value");
- }
- }
-
- public List<ExpressionResult> getList() {
- if (null == expressionResults) {
- List<ExpressionResult> a = new ArrayList<ExpressionResult>(20);
- a.add(new ExpressionResult(dataType, value));
- return a;
- } else {
- return expressionResults;
- }
- }
-
- public List<String> getListAsString() {
- List<String> evaluateResultListFinal = new ArrayList<String>(20);
- List<ExpressionResult> evaluateResultList = getList();
- for (ExpressionResult result : evaluateResultList) {
- if (result.getString() == null) {
- evaluateResultListFinal.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL);
- continue;
- }
- evaluateResultListFinal.add(result.getString());
- }
- return evaluateResultListFinal;
- }
-
- @Override public int hashCode() {
- final int prime = 31;
- int result = 1;
- if (null != expressionResults) {
- result = prime * result + expressionResults.hashCode();
- } else if (null != value) {
- result = prime * result + value.toString().hashCode();
- } else {
- result = prime * result + "".hashCode();
- }
-
- return result;
- }
-
- @Override public boolean equals(Object obj) {
- if (!(obj instanceof ExpressionResult)) {
- return false;
- }
- if (this == obj) {
- return true;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- ExpressionResult objToCompare = (ExpressionResult) obj;
- boolean result = false;
- if (this.value == objToCompare.value) {
- return true;
- }
- try {
- switch (this.getDataType()) {
- case StringType:
- result = this.getString().equals(objToCompare.getString());
- break;
- case IntegerType:
- result = this.getInt().equals(objToCompare.getInt());
- break;
-
- case DoubleType:
- result = this.getDouble().equals(objToCompare.getDouble());
- break;
- case TimestampType:
- result = this.getLong().equals(objToCompare.getLong());
- break;
- default:
- break;
- }
- } catch (FilterUnsupportedException ex) {
- return false;
- }
-
- return result;
- }
-
- public boolean isNull() {
- return value == null;
- }
-
- @Override public int compareTo(ExpressionResult o) {
- try {
- switch (o.dataType) {
- case IntegerType:
- case LongType:
- case DoubleType:
-
- Double d1 = this.getDouble();
- Double d2 = o.getDouble();
- return d1.compareTo(d2);
- case DecimalType:
- java.math.BigDecimal val1 = this.getDecimal();
- java.math.BigDecimal val2 = o.getDecimal();
- return val1.compareTo(val2);
- case TimestampType:
- SimpleDateFormat parser = new SimpleDateFormat(CarbonProperties.getInstance()
- .getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
- CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT));
- Date date1 = null;
- Date date2 = null;
- date1 = parser.parse(this.getString());
- date2 = parser.parse(o.getString());
- return date1.compareTo(date2);
- case StringType:
- default:
- return this.getString().compareTo(o.getString());
- }
- } catch (Exception e) {
- return -1;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/1c725f5b/core/src/main/java/org/carbondata/query/expression/LeafExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/LeafExpression.java b/core/src/main/java/org/carbondata/query/expression/LeafExpression.java
deleted file mode 100644
index 41093ad..0000000
--- a/core/src/main/java/org/carbondata/query/expression/LeafExpression.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * 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.query.expression;
-
-public abstract class LeafExpression extends Expression {
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/1c725f5b/core/src/main/java/org/carbondata/query/expression/LiteralExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/LiteralExpression.java b/core/src/main/java/org/carbondata/query/expression/LiteralExpression.java
deleted file mode 100644
index ccad46e..0000000
--- a/core/src/main/java/org/carbondata/query/expression/LiteralExpression.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.query.expression;
-
-import org.carbondata.query.carbonfilterinterface.ExpressionType;
-import org.carbondata.query.carbonfilterinterface.RowIntf;
-
-public class LiteralExpression extends LeafExpression {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private Object value;
- private DataType dataType;
-
- public LiteralExpression(Object value, DataType dataType) {
- this.value = value;
- this.dataType = dataType;
- }
-
- @Override public ExpressionResult evaluate(RowIntf value) {
- ExpressionResult expressionResult = new ExpressionResult(dataType, this.value);
- return expressionResult;
- }
-
- public ExpressionResult getExpressionResult() {
- ExpressionResult expressionResult = new ExpressionResult(dataType, this.value);
- return expressionResult;
- }
-
- @Override public ExpressionType getFilterExpressionType() {
- // TODO Auto-generated method stub
- return ExpressionType.LITERAL;
- }
-
- @Override public String getString() {
- // TODO Auto-generated method stub
- return "LiteralExpression(" + value + ')';
- }
-
- /**
- * getLiteralExpDataType.
- *
- * @return
- */
- public DataType getLiteralExpDataType() {
- return dataType;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/1c725f5b/core/src/main/java/org/carbondata/query/expression/UnaryExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/UnaryExpression.java b/core/src/main/java/org/carbondata/query/expression/UnaryExpression.java
deleted file mode 100644
index e8250f9..0000000
--- a/core/src/main/java/org/carbondata/query/expression/UnaryExpression.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.query.expression;
-
-public abstract class UnaryExpression extends Expression {
-
- private static final long serialVersionUID = 1L;
- protected Expression child;
-
- public UnaryExpression(Expression child) {
- this.child = child;
- children.add(child);
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/1c725f5b/core/src/main/java/org/carbondata/query/expression/UnknownExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/UnknownExpression.java b/core/src/main/java/org/carbondata/query/expression/UnknownExpression.java
deleted file mode 100644
index c3553d8..0000000
--- a/core/src/main/java/org/carbondata/query/expression/UnknownExpression.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.carbondata.query.expression;
-
-import java.util.List;
-
-public abstract class UnknownExpression extends Expression {
-
- public abstract List<ColumnExpression> getAllColumnList();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/1c725f5b/core/src/main/java/org/carbondata/query/expression/arithmetic/AddExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/arithmetic/AddExpression.java b/core/src/main/java/org/carbondata/query/expression/arithmetic/AddExpression.java
deleted file mode 100644
index bb17da4..0000000
--- a/core/src/main/java/org/carbondata/query/expression/arithmetic/AddExpression.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.query.expression.arithmetic;
-
-import org.carbondata.query.carbonfilterinterface.ExpressionType;
-import org.carbondata.query.carbonfilterinterface.RowIntf;
-import org.carbondata.query.expression.DataType;
-import org.carbondata.query.expression.Expression;
-import org.carbondata.query.expression.ExpressionResult;
-import org.carbondata.query.expression.exception.FilterUnsupportedException;
-
-public class AddExpression extends BinaryArithmeticExpression {
- private static final long serialVersionUID = 7999436055420911612L;
-
- public AddExpression(Expression left, Expression right) {
- super(left, right);
- }
-
- @Override public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException {
- ExpressionResult addExprLeftRes = left.evaluate(value);
- ExpressionResult addExprRightRes = right.evaluate(value);
- ExpressionResult val1 = addExprLeftRes;
- ExpressionResult val2 = addExprRightRes;
- if (addExprLeftRes.isNull() || addExprRightRes.isNull()) {
- addExprLeftRes.set(addExprLeftRes.getDataType(), null);
- return addExprLeftRes;
- }
-
- if (addExprLeftRes.getDataType() != addExprRightRes.getDataType()) {
- if (addExprLeftRes.getDataType().getPresedenceOrder() < addExprRightRes.getDataType()
- .getPresedenceOrder()) {
- val2 = addExprLeftRes;
- val1 = addExprRightRes;
- }
- }
- switch (val1.getDataType()) {
- case StringType:
- case DoubleType:
- addExprRightRes.set(DataType.DoubleType, val1.getDouble() + val2.getDouble());
- break;
- case IntegerType:
- addExprRightRes.set(DataType.IntegerType, val1.getInt() + val2.getInt());
- break;
- case LongType:
- addExprRightRes.set(DataType.LongType, val1.getLong() + val2.getLong());
- break;
- case DecimalType:
- addExprRightRes.set(DataType.DecimalType, val1.getDecimal().add(val2.getDecimal()));
- break;
- default:
- throw new FilterUnsupportedException(
- "Incompatible datatype for applying Add Expression Filter " + val1.getDataType());
- }
- return addExprRightRes;
- }
-
- @Override public ExpressionType getFilterExpressionType() {
- return ExpressionType.ADD;
- }
-
- @Override public String getString() {
- return "Add(" + left.getString() + ',' + right.getString() + ',';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/1c725f5b/core/src/main/java/org/carbondata/query/expression/arithmetic/BinaryArithmeticExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/arithmetic/BinaryArithmeticExpression.java b/core/src/main/java/org/carbondata/query/expression/arithmetic/BinaryArithmeticExpression.java
deleted file mode 100644
index 78f5990..0000000
--- a/core/src/main/java/org/carbondata/query/expression/arithmetic/BinaryArithmeticExpression.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.query.expression.arithmetic;
-
-import org.carbondata.query.expression.BinaryExpression;
-import org.carbondata.query.expression.Expression;
-
-public abstract class BinaryArithmeticExpression extends BinaryExpression {
-
- private static final long serialVersionUID = 1L;
-
- public BinaryArithmeticExpression(Expression left, Expression right) {
- super(left, right);
- // TODO Auto-generated constructor stub
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/1c725f5b/core/src/main/java/org/carbondata/query/expression/arithmetic/DivideExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/arithmetic/DivideExpression.java b/core/src/main/java/org/carbondata/query/expression/arithmetic/DivideExpression.java
deleted file mode 100644
index f1750a0..0000000
--- a/core/src/main/java/org/carbondata/query/expression/arithmetic/DivideExpression.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.query.expression.arithmetic;
-
-import org.carbondata.query.carbonfilterinterface.ExpressionType;
-import org.carbondata.query.carbonfilterinterface.RowIntf;
-import org.carbondata.query.expression.DataType;
-import org.carbondata.query.expression.Expression;
-import org.carbondata.query.expression.ExpressionResult;
-import org.carbondata.query.expression.exception.FilterUnsupportedException;
-
-public class DivideExpression extends BinaryArithmeticExpression {
- private static final long serialVersionUID = -7269266926782365612L;
-
- public DivideExpression(Expression left, Expression right) {
- super(left, right);
- }
-
- @Override public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException {
- ExpressionResult divideExprLeftRes = left.evaluate(value);
- ExpressionResult divideExprRightRes = right.evaluate(value);
- ExpressionResult val1 = divideExprLeftRes;
- ExpressionResult val2 = divideExprRightRes;
- if (divideExprLeftRes.isNull() || divideExprRightRes.isNull()) {
- divideExprLeftRes.set(divideExprLeftRes.getDataType(), null);
- return divideExprLeftRes;
- }
- if (divideExprLeftRes.getDataType() != divideExprRightRes.getDataType()) {
- if (divideExprLeftRes.getDataType().getPresedenceOrder() < divideExprRightRes.getDataType()
- .getPresedenceOrder()) {
- val2 = divideExprLeftRes;
- val1 = divideExprRightRes;
- }
- }
- switch (val1.getDataType()) {
- case StringType:
- case DoubleType:
- divideExprRightRes.set(DataType.DoubleType, val1.getDouble() / val2.getDouble());
- break;
- case IntegerType:
- divideExprRightRes.set(DataType.IntegerType, val1.getInt() / val2.getInt());
- break;
- case LongType:
- divideExprRightRes.set(DataType.LongType, val1.getLong() / val2.getLong());
- break;
- case DecimalType:
- divideExprRightRes.set(DataType.DecimalType, val1.getDecimal().divide(val2.getDecimal()));
- break;
- default:
- throw new FilterUnsupportedException(
- "Incompatible datatype for applying Add Expression Filter " + divideExprLeftRes
- .getDataType());
- }
- return divideExprRightRes;
- }
-
- @Override public ExpressionType getFilterExpressionType() {
- return ExpressionType.DIVIDE;
- }
-
- @Override public String getString() {
- return "Divide(" + left.getString() + ',' + right.getString() + ')';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/1c725f5b/core/src/main/java/org/carbondata/query/expression/arithmetic/MultiplyExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/arithmetic/MultiplyExpression.java b/core/src/main/java/org/carbondata/query/expression/arithmetic/MultiplyExpression.java
deleted file mode 100644
index 5d02dda..0000000
--- a/core/src/main/java/org/carbondata/query/expression/arithmetic/MultiplyExpression.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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.query.expression.arithmetic;
-
-import org.carbondata.query.carbonfilterinterface.ExpressionType;
-import org.carbondata.query.carbonfilterinterface.RowIntf;
-import org.carbondata.query.expression.DataType;
-import org.carbondata.query.expression.Expression;
-import org.carbondata.query.expression.ExpressionResult;
-import org.carbondata.query.expression.exception.FilterUnsupportedException;
-
-public class MultiplyExpression extends BinaryArithmeticExpression {
- private static final long serialVersionUID = 1L;
-
- public MultiplyExpression(Expression left, Expression right) {
- super(left, right);
- }
-
- @Override public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException {
- ExpressionResult multiplyExprLeftRes = left.evaluate(value);
- ExpressionResult multiplyExprRightRes = right.evaluate(value);
- ExpressionResult val1 = multiplyExprLeftRes;
- ExpressionResult val2 = multiplyExprRightRes;
- if (multiplyExprLeftRes.isNull() || multiplyExprRightRes.isNull()) {
- multiplyExprLeftRes.set(multiplyExprLeftRes.getDataType(), null);
- return multiplyExprLeftRes;
- }
-
- if (multiplyExprLeftRes.getDataType() != multiplyExprRightRes.getDataType()) {
- if (multiplyExprLeftRes.getDataType().getPresedenceOrder() < multiplyExprRightRes
- .getDataType().getPresedenceOrder()) {
- val2 = multiplyExprLeftRes;
- val1 = multiplyExprRightRes;
- }
- }
- switch (val1.getDataType()) {
- case StringType:
- case DoubleType:
- multiplyExprRightRes.set(DataType.DoubleType, val1.getDouble() * val2.getDouble());
- break;
- case IntegerType:
- multiplyExprRightRes.set(DataType.IntegerType, val1.getInt() * val2.getInt());
- break;
- case LongType:
- multiplyExprRightRes.set(DataType.LongType, val1.getLong() * val2.getLong());
- break;
- case DecimalType:
- multiplyExprRightRes
- .set(DataType.DecimalType, val1.getDecimal().multiply(val2.getDecimal()));
- break;
- default:
- throw new FilterUnsupportedException(
- "Incompatible datatype for applying Add Expression Filter " + multiplyExprLeftRes
- .getDataType());
- }
- return multiplyExprRightRes;
- }
-
- @Override public ExpressionType getFilterExpressionType() {
- return ExpressionType.MULTIPLY;
- }
-
- @Override public String getString() {
- return "Substract(" + left.getString() + ',' + right.getString() + ')';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/1c725f5b/core/src/main/java/org/carbondata/query/expression/arithmetic/SubstractExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/arithmetic/SubstractExpression.java b/core/src/main/java/org/carbondata/query/expression/arithmetic/SubstractExpression.java
deleted file mode 100644
index df1999a..0000000
--- a/core/src/main/java/org/carbondata/query/expression/arithmetic/SubstractExpression.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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.query.expression.arithmetic;
-
-import org.carbondata.query.carbonfilterinterface.ExpressionType;
-import org.carbondata.query.carbonfilterinterface.RowIntf;
-import org.carbondata.query.expression.DataType;
-import org.carbondata.query.expression.Expression;
-import org.carbondata.query.expression.ExpressionResult;
-import org.carbondata.query.expression.exception.FilterUnsupportedException;
-
-public class SubstractExpression extends BinaryArithmeticExpression {
-
- private static final long serialVersionUID = -8304726440185363102L;
-
- public SubstractExpression(Expression left, Expression right) {
- super(left, right);
- }
-
- @Override public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException {
- ExpressionResult subtractExprLeftRes = left.evaluate(value);
- ExpressionResult subtractExprRightRes = right.evaluate(value);
- ExpressionResult val1 = subtractExprLeftRes;
- ExpressionResult val2 = subtractExprRightRes;
- if (subtractExprLeftRes.isNull() || subtractExprRightRes.isNull()) {
- subtractExprLeftRes.set(subtractExprLeftRes.getDataType(), null);
- return subtractExprLeftRes;
- }
- if (subtractExprLeftRes.getDataType() != subtractExprRightRes.getDataType()) {
- if (subtractExprLeftRes.getDataType().getPresedenceOrder() < subtractExprRightRes
- .getDataType().getPresedenceOrder()) {
- val2 = subtractExprLeftRes;
- val1 = subtractExprRightRes;
- }
- }
- switch (val1.getDataType()) {
- case StringType:
- case DoubleType:
- subtractExprRightRes.set(DataType.DoubleType, val1.getDouble() - val2.getDouble());
- break;
- case IntegerType:
- subtractExprRightRes.set(DataType.IntegerType, val1.getInt() - val2.getInt());
- break;
- case LongType:
- subtractExprRightRes.set(DataType.LongType, val1.getLong() - val2.getLong());
- break;
- case DecimalType:
- subtractExprRightRes
- .set(DataType.DecimalType, val1.getDecimal().subtract(val2.getDecimal()));
- break;
- default:
- throw new FilterUnsupportedException(
- "Incompatible datatype for applying Add Expression Filter " + subtractExprLeftRes
- .getDataType());
- }
- return subtractExprRightRes;
- }
-
- @Override public ExpressionType getFilterExpressionType() {
- return ExpressionType.SUBSTRACT;
- }
-
- @Override public String getString() {
- return "Substract(" + left.getString() + ',' + right.getString() + ')';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/1c725f5b/core/src/main/java/org/carbondata/query/expression/conditional/BinaryConditionalExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/conditional/BinaryConditionalExpression.java b/core/src/main/java/org/carbondata/query/expression/conditional/BinaryConditionalExpression.java
deleted file mode 100644
index 5b347fd..0000000
--- a/core/src/main/java/org/carbondata/query/expression/conditional/BinaryConditionalExpression.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.query.expression.conditional;
-
-import org.carbondata.query.expression.Expression;
-import org.carbondata.query.expression.logical.BinaryLogicalExpression;
-
-public abstract class BinaryConditionalExpression extends BinaryLogicalExpression
- implements ConditionalExpression {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- public BinaryConditionalExpression(Expression left, Expression right) {
- super(left, right);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/1c725f5b/core/src/main/java/org/carbondata/query/expression/conditional/ConditionalExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/conditional/ConditionalExpression.java b/core/src/main/java/org/carbondata/query/expression/conditional/ConditionalExpression.java
deleted file mode 100644
index 12a990d..0000000
--- a/core/src/main/java/org/carbondata/query/expression/conditional/ConditionalExpression.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.query.expression.conditional;
-
-import java.util.List;
-
-import org.carbondata.query.expression.ColumnExpression;
-import org.carbondata.query.expression.ExpressionResult;
-
-public interface ConditionalExpression {
-
- // Will get the column informations involved in the expressions by
- // traversing the tree
- List<ColumnExpression> getColumnList();
-
- boolean isSingleDimension();
-
- List<ExpressionResult> getLiterals();
-
- /**
- * will return the flag of direct dictionary column
- *
- * @return
- */
- boolean isDirectDictionaryColumns();
-}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/1c725f5b/core/src/main/java/org/carbondata/query/expression/conditional/EqualToExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/conditional/EqualToExpression.java b/core/src/main/java/org/carbondata/query/expression/conditional/EqualToExpression.java
deleted file mode 100644
index eb180f6..0000000
--- a/core/src/main/java/org/carbondata/query/expression/conditional/EqualToExpression.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.query.expression.conditional;
-
-import org.carbondata.query.carbonfilterinterface.ExpressionType;
-import org.carbondata.query.carbonfilterinterface.RowIntf;
-import org.carbondata.query.expression.DataType;
-import org.carbondata.query.expression.Expression;
-import org.carbondata.query.expression.ExpressionResult;
-import org.carbondata.query.expression.exception.FilterUnsupportedException;
-
-public class EqualToExpression extends BinaryConditionalExpression {
-
- private static final long serialVersionUID = 1L;
-
- public EqualToExpression(Expression left, Expression right) {
- super(left, right);
- }
-
- @Override public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException {
- 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()) {
- if (elRes.getDataType().getPresedenceOrder() < erRes.getDataType().getPresedenceOrder()) {
- val2 = elRes;
- val1 = erRes;
- }
- }
-
- // todo: move to util
- switch (val1.getDataType()) {
- case StringType:
- result = val1.getString().equals(val2.getString());
- break;
- case IntegerType:
- result = val1.getInt().equals(val2.getInt());
- break;
- case DoubleType:
- result = val1.getDouble().equals(val2.getDouble());
- break;
- case TimestampType:
- result = val1.getTime().equals(val2.getTime());
- break;
- case LongType:
- result = val1.getLong().equals(val2.getLong());
- break;
- case DecimalType:
- result = val1.getDecimal().compareTo(val2.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.EQUALS;
- }
-
- @Override public String getString() {
- return "EqualTo(" + left.getString() + ',' + right.getString() + ')';
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/1c725f5b/core/src/main/java/org/carbondata/query/expression/conditional/GreaterThanEqualToExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/conditional/GreaterThanEqualToExpression.java b/core/src/main/java/org/carbondata/query/expression/conditional/GreaterThanEqualToExpression.java
deleted file mode 100644
index 5a8cdae..0000000
--- a/core/src/main/java/org/carbondata/query/expression/conditional/GreaterThanEqualToExpression.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.query.expression.conditional;
-
-import org.carbondata.query.carbonfilterinterface.ExpressionType;
-import org.carbondata.query.carbonfilterinterface.RowIntf;
-import org.carbondata.query.expression.DataType;
-import org.carbondata.query.expression.Expression;
-import org.carbondata.query.expression.ExpressionResult;
-import org.carbondata.query.expression.exception.FilterUnsupportedException;
-
-public class GreaterThanEqualToExpression extends BinaryConditionalExpression {
- private static final long serialVersionUID = 4185317066280688984L;
-
- public GreaterThanEqualToExpression(Expression left, Expression right) {
- super(left, right);
- }
-
- public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException {
- ExpressionResult elRes = left.evaluate(value);
- ExpressionResult erRes = right.evaluate(value);
- ExpressionResult exprResVal1 = 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()) {
- exprResVal1 = erRes;
- }
-
- }
- boolean result = false;
- switch (exprResVal1.getDataType()) {
- case StringType:
- result = elRes.getString().compareTo(erRes.getString()) >= 0;
- 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: " + exprResVal1.getDataType() + " not supported for the filter expression");
- }
- exprResVal1.set(DataType.BooleanType, result);
- return exprResVal1;
- }
-
- @Override public ExpressionType getFilterExpressionType() {
- return ExpressionType.GREATERTHAN_EQUALTO;
- }
-
- @Override public String getString() {
- return "GreaterThanEqualTo(" + left.getString() + ',' + right.getString() + ')';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/1c725f5b/core/src/main/java/org/carbondata/query/expression/conditional/GreaterThanExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/conditional/GreaterThanExpression.java b/core/src/main/java/org/carbondata/query/expression/conditional/GreaterThanExpression.java
deleted file mode 100644
index 743bfd2..0000000
--- a/core/src/main/java/org/carbondata/query/expression/conditional/GreaterThanExpression.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.query.expression.conditional;
-
-import org.carbondata.query.carbonfilterinterface.ExpressionType;
-import org.carbondata.query.carbonfilterinterface.RowIntf;
-import org.carbondata.query.expression.DataType;
-import org.carbondata.query.expression.Expression;
-import org.carbondata.query.expression.ExpressionResult;
-import org.carbondata.query.expression.exception.FilterUnsupportedException;
-
-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 {
- 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 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/1c725f5b/core/src/main/java/org/carbondata/query/expression/conditional/InExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/conditional/InExpression.java b/core/src/main/java/org/carbondata/query/expression/conditional/InExpression.java
deleted file mode 100644
index cc1feaf..0000000
--- a/core/src/main/java/org/carbondata/query/expression/conditional/InExpression.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.query.expression.conditional;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.carbondata.query.carbonfilterinterface.ExpressionType;
-import org.carbondata.query.carbonfilterinterface.RowIntf;
-import org.carbondata.query.expression.DataType;
-import org.carbondata.query.expression.Expression;
-import org.carbondata.query.expression.ExpressionResult;
-import org.carbondata.query.expression.exception.FilterUnsupportedException;
-
-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 {
- 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 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/1c725f5b/core/src/main/java/org/carbondata/query/expression/conditional/LessThanEqualToExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/conditional/LessThanEqualToExpression.java b/core/src/main/java/org/carbondata/query/expression/conditional/LessThanEqualToExpression.java
deleted file mode 100644
index a40765b..0000000
--- a/core/src/main/java/org/carbondata/query/expression/conditional/LessThanEqualToExpression.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.query.expression.conditional;
-
-import org.carbondata.query.carbonfilterinterface.ExpressionType;
-import org.carbondata.query.carbonfilterinterface.RowIntf;
-import org.carbondata.query.expression.DataType;
-import org.carbondata.query.expression.Expression;
-import org.carbondata.query.expression.ExpressionResult;
-import org.carbondata.query.expression.exception.FilterUnsupportedException;
-
-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 {
- 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 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/1c725f5b/core/src/main/java/org/carbondata/query/expression/conditional/LessThanExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/conditional/LessThanExpression.java b/core/src/main/java/org/carbondata/query/expression/conditional/LessThanExpression.java
deleted file mode 100644
index 8dacc15..0000000
--- a/core/src/main/java/org/carbondata/query/expression/conditional/LessThanExpression.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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.query.expression.conditional;
-
-import org.carbondata.query.carbonfilterinterface.ExpressionType;
-import org.carbondata.query.carbonfilterinterface.RowIntf;
-import org.carbondata.query.expression.DataType;
-import org.carbondata.query.expression.Expression;
-import org.carbondata.query.expression.ExpressionResult;
-import org.carbondata.query.expression.exception.FilterUnsupportedException;
-
-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 {
- 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 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() + ')';
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/1c725f5b/core/src/main/java/org/carbondata/query/expression/conditional/ListExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/conditional/ListExpression.java b/core/src/main/java/org/carbondata/query/expression/conditional/ListExpression.java
deleted file mode 100644
index 2c7df01..0000000
--- a/core/src/main/java/org/carbondata/query/expression/conditional/ListExpression.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.query.expression.conditional;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.carbondata.query.carbonfilterinterface.ExpressionType;
-import org.carbondata.query.carbonfilterinterface.RowIntf;
-import org.carbondata.query.expression.Expression;
-import org.carbondata.query.expression.ExpressionResult;
-import org.carbondata.query.expression.exception.FilterUnsupportedException;
-
-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));
- }
- 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/1c725f5b/core/src/main/java/org/carbondata/query/expression/conditional/NotEqualsExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/conditional/NotEqualsExpression.java b/core/src/main/java/org/carbondata/query/expression/conditional/NotEqualsExpression.java
deleted file mode 100644
index 94957eb..0000000
--- a/core/src/main/java/org/carbondata/query/expression/conditional/NotEqualsExpression.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.query.expression.conditional;
-
-import org.carbondata.query.carbonfilterinterface.ExpressionType;
-import org.carbondata.query.carbonfilterinterface.RowIntf;
-import org.carbondata.query.expression.DataType;
-import org.carbondata.query.expression.Expression;
-import org.carbondata.query.expression.ExpressionResult;
-import org.carbondata.query.expression.exception.FilterUnsupportedException;
-
-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 {
- 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 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/1c725f5b/core/src/main/java/org/carbondata/query/expression/conditional/NotInExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/conditional/NotInExpression.java b/core/src/main/java/org/carbondata/query/expression/conditional/NotInExpression.java
deleted file mode 100644
index c2ef28f..0000000
--- a/core/src/main/java/org/carbondata/query/expression/conditional/NotInExpression.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.query.expression.conditional;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.carbondata.query.carbonfilterinterface.ExpressionType;
-import org.carbondata.query.carbonfilterinterface.RowIntf;
-import org.carbondata.query.expression.DataType;
-import org.carbondata.query.expression.Expression;
-import org.carbondata.query.expression.ExpressionResult;
-import org.carbondata.query.expression.exception.FilterUnsupportedException;
-
-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 {
- 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 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/1c725f5b/core/src/main/java/org/carbondata/query/expression/exception/FilterUnsupportedException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/exception/FilterUnsupportedException.java b/core/src/main/java/org/carbondata/query/expression/exception/FilterUnsupportedException.java
deleted file mode 100644
index 62267bf..0000000
--- a/core/src/main/java/org/carbondata/query/expression/exception/FilterUnsupportedException.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.query.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/1c725f5b/core/src/main/java/org/carbondata/query/expression/logical/AndExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/logical/AndExpression.java b/core/src/main/java/org/carbondata/query/expression/logical/AndExpression.java
deleted file mode 100644
index e74daf2..0000000
--- a/core/src/main/java/org/carbondata/query/expression/logical/AndExpression.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.query.expression.logical;
-
-import org.carbondata.query.carbonfilterinterface.ExpressionType;
-import org.carbondata.query.carbonfilterinterface.RowIntf;
-import org.carbondata.query.expression.DataType;
-import org.carbondata.query.expression.Expression;
-import org.carbondata.query.expression.ExpressionResult;
-import org.carbondata.query.expression.exception.FilterUnsupportedException;
-
-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 {
- 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/1c725f5b/core/src/main/java/org/carbondata/query/expression/logical/BinaryLogicalExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/logical/BinaryLogicalExpression.java b/core/src/main/java/org/carbondata/query/expression/logical/BinaryLogicalExpression.java
deleted file mode 100644
index 44173f7..0000000
--- a/core/src/main/java/org/carbondata/query/expression/logical/BinaryLogicalExpression.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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.query.expression.logical;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.carbondata.core.carbon.metadata.encoder.Encoding;
-import org.carbondata.core.constants.CarbonCommonConstants;
-import org.carbondata.query.expression.BinaryExpression;
-import org.carbondata.query.expression.ColumnExpression;
-import org.carbondata.query.expression.Expression;
-import org.carbondata.query.expression.ExpressionResult;
-import org.carbondata.query.expression.LiteralExpression;
-
-public abstract class BinaryLogicalExpression extends BinaryExpression {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- public BinaryLogicalExpression(Expression left, Expression right) {
- super(left, right);
- // TODO Auto-generated constructor stub
- }
-
- public List<ExpressionResult> getLiterals() {
- List<ExpressionResult> listOfExp =
- new ArrayList<ExpressionResult>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
- getExpressionResultList(this, listOfExp);
- Collections.sort(listOfExp);
- return listOfExp;
- }
-
- // Will get the column informations involved in the expressions by
- // traversing the tree
- public List<ColumnExpression> getColumnList() {
- // TODO
- List<ColumnExpression> listOfExp =
- new ArrayList<ColumnExpression>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
- getColumnList(this, listOfExp);
- return listOfExp;
- }
-
- private void getColumnList(Expression expression, List<ColumnExpression> lst) {
- if (expression instanceof ColumnExpression) {
- ColumnExpression colExp = (ColumnExpression) expression;
- boolean found = false;
-
- for (ColumnExpression currentColExp : lst) {
- if (currentColExp.getColumnName().equals(colExp.getColumnName())) {
- found = true;
- colExp.setColIndex(currentColExp.getColIndex());
- break;
- }
- }
- if (!found) {
- colExp.setColIndex(lst.size());
- lst.add(colExp);
- }
- }
- for (Expression child : expression.getChildren()) {
- getColumnList(child, lst);
- }
- }
-
- public boolean isSingleDimension() {
- List<ColumnExpression> listOfExp =
- new ArrayList<ColumnExpression>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
- getColumnList(this, listOfExp);
- if (listOfExp.size() == 1 && listOfExp.get(0).isDimension()) {
- return true;
- }
- return false;
-
- }
-
- private void getExpressionResultList(Expression binaryConditionalExpression,
- List<ExpressionResult> listOfExp) {
- if (binaryConditionalExpression instanceof LiteralExpression) {
- ExpressionResult colExp =
- ((LiteralExpression) binaryConditionalExpression).getExpressionResult();
- listOfExp.add(colExp);
- }
- for (Expression child : binaryConditionalExpression.getChildren()) {
- getExpressionResultList(child, listOfExp);
- }
-
- }
-
- /**
- * the method will return flag (true or false) depending on the existence of the
- * direct dictionary columns in conditional expression
- *
- * @return the method will return flag (true or false)
- */
- public boolean isDirectDictionaryColumns() {
- List<ColumnExpression> listOfExp =
- new ArrayList<ColumnExpression>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
- getColumnList(this, listOfExp);
- for (ColumnExpression ce : listOfExp) {
- if (!ce.getCarbonColumn().hasEncoding(Encoding.DICTIONARY)) {
- return true;
- }
- }
- return false;
- }
-}