This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Text and Keyword Data Type (#620)
* Add Text and Keyword Data Type * update * address comments
- Loading branch information
Showing
46 changed files
with
1,366 additions
and
511 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
...in/java/com/amazon/opendistroforelasticsearch/sql/data/model/AbstractExprNumberValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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 com.amazon.opendistroforelasticsearch.sql.data.model; | ||
|
||
import com.google.common.base.Objects; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
/** | ||
* Expression Number Value. | ||
*/ | ||
@RequiredArgsConstructor | ||
public abstract class AbstractExprNumberValue extends AbstractExprValue { | ||
private final Number value; | ||
|
||
@Override | ||
public Integer integerValue() { | ||
return value.intValue(); | ||
} | ||
|
||
@Override | ||
public Long longValue() { | ||
return value.longValue(); | ||
} | ||
|
||
@Override | ||
public Float floatValue() { | ||
return value.floatValue(); | ||
} | ||
|
||
@Override | ||
public Double doubleValue() { | ||
return value.doubleValue(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(value); | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
...src/main/java/com/amazon/opendistroforelasticsearch/sql/data/model/AbstractExprValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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 com.amazon.opendistroforelasticsearch.sql.data.model; | ||
|
||
import com.amazon.opendistroforelasticsearch.sql.exception.ExpressionEvaluationException; | ||
|
||
/** | ||
* Abstract ExprValue. | ||
*/ | ||
public abstract class AbstractExprValue implements ExprValue { | ||
/** | ||
* The customize compareTo logic. | ||
*/ | ||
@Override | ||
public int compareTo(ExprValue other) { | ||
if (this.isNull() || this.isMissing()) { | ||
return this.compare(other); | ||
} else if (other.isNull() || other.isMissing()) { | ||
return -other.compareTo(this); | ||
} | ||
if (!this.type().equals(other.type())) { | ||
throw new ExpressionEvaluationException( | ||
String.format( | ||
"compare expected value have same type, but with [%s, %s]", | ||
this.type(), other.type())); | ||
} | ||
return compare(other); | ||
} | ||
|
||
/** | ||
* The customize equals logic. | ||
* The table below list the NULL and MISSING handling logic. | ||
* A B A == B | ||
* NULL NULL TRUE | ||
* NULL MISSING FALSE | ||
* MISSING NULL FALSE | ||
* MISSING MISSING TRUE | ||
*/ | ||
@Override | ||
public boolean equals(Object o) { | ||
if (o == this) { | ||
return true; | ||
} else if (!(o instanceof ExprValue)) { | ||
return false; | ||
} | ||
ExprValue other = (ExprValue) o; | ||
if (this.isNull() || this.isMissing()) { | ||
return equal(other); | ||
} else if (other.isNull() || other.isMissing()) { | ||
return other.equals(this); | ||
} else { | ||
return equal(other); | ||
} | ||
} | ||
|
||
/** | ||
* The expression value compare. | ||
*/ | ||
public abstract int compare(ExprValue other); | ||
|
||
/** | ||
* The expression value equal. | ||
*/ | ||
public abstract boolean equal(ExprValue other); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.