1
|
|
/* |
2
|
|
* Copyright OpenSearch Contributors |
3
|
|
* SPDX-License-Identifier: Apache-2.0 |
4
|
|
*/ |
5
|
|
|
6
|
|
|
7
|
|
package org.opensearch.sql.data.model; |
8
|
|
|
9
|
|
import org.opensearch.sql.exception.ExpressionEvaluationException; |
10
|
|
|
11
|
|
/** |
12
|
|
* Abstract ExprValue. |
13
|
|
*/ |
14
|
|
public abstract class AbstractExprValue implements ExprValue { |
15
|
|
/** |
16
|
|
* The customize compareTo logic. |
17
|
|
*/ |
18
|
|
@Override |
19
|
|
public int compareTo(ExprValue other) { |
20
|
4
1. compareTo : negated conditional → KILLED
2. compareTo : negated conditional → KILLED
3. compareTo : negated conditional → KILLED
4. compareTo : negated conditional → KILLED
|
if (this.isNull() || this.isMissing() || other.isNull() || other.isMissing()) { |
21
|
|
throw new IllegalStateException( |
22
|
|
String.format("[BUG] Unreachable, Comparing with NULL or MISSING is undefined")); |
23
|
|
} |
24
|
3
1. compareTo : negated conditional → KILLED
2. compareTo : negated conditional → KILLED
3. compareTo : negated conditional → KILLED
|
if ((this.isNumber() && other.isNumber()) || this.type() == other.type()) { |
25
|
1
1. compareTo : replaced int return with 0 for org/opensearch/sql/data/model/AbstractExprValue::compareTo → KILLED
|
return compare(other); |
26
|
|
} else { |
27
|
|
throw new ExpressionEvaluationException( |
28
|
|
String.format( |
29
|
|
"compare expected value have same type, but with [%s, %s]", |
30
|
|
this.type(), other.type())); |
31
|
|
} |
32
|
|
} |
33
|
|
|
34
|
|
/** |
35
|
|
* The customize equals logic. |
36
|
|
* The table below list the NULL and MISSING handling logic. |
37
|
|
* A B A == B |
38
|
|
* NULL NULL TRUE |
39
|
|
* NULL MISSING FALSE |
40
|
|
* MISSING NULL FALSE |
41
|
|
* MISSING MISSING TRUE |
42
|
|
*/ |
43
|
|
@Override |
44
|
|
public boolean equals(Object o) { |
45
|
1
1. equals : negated conditional → KILLED
|
if (o == this) { |
46
|
1
1. equals : replaced boolean return with false for org/opensearch/sql/data/model/AbstractExprValue::equals → KILLED
|
return true; |
47
|
1
1. equals : negated conditional → KILLED
|
} else if (!(o instanceof ExprValue)) { |
48
|
1
1. equals : replaced boolean return with true for org/opensearch/sql/data/model/AbstractExprValue::equals → KILLED
|
return false; |
49
|
|
} |
50
|
|
ExprValue other = (ExprValue) o; |
51
|
2
1. equals : negated conditional → KILLED
2. equals : negated conditional → KILLED
|
if (this.isNull() || this.isMissing()) { |
52
|
2
1. equals : replaced boolean return with false for org/opensearch/sql/data/model/AbstractExprValue::equals → SURVIVED
2. equals : replaced boolean return with true for org/opensearch/sql/data/model/AbstractExprValue::equals → KILLED
|
return equal(other); |
53
|
2
1. equals : negated conditional → KILLED
2. equals : negated conditional → KILLED
|
} else if (other.isNull() || other.isMissing()) { |
54
|
2
1. equals : replaced boolean return with false for org/opensearch/sql/data/model/AbstractExprValue::equals → SURVIVED
2. equals : replaced boolean return with true for org/opensearch/sql/data/model/AbstractExprValue::equals → KILLED
|
return other.equals(this); |
55
|
|
} else { |
56
|
2
1. equals : replaced boolean return with false for org/opensearch/sql/data/model/AbstractExprValue::equals → KILLED
2. equals : replaced boolean return with true for org/opensearch/sql/data/model/AbstractExprValue::equals → KILLED
|
return equal(other); |
57
|
|
} |
58
|
|
} |
59
|
|
|
60
|
|
/** |
61
|
|
* The expression value compare. |
62
|
|
*/ |
63
|
|
public abstract int compare(ExprValue other); |
64
|
|
|
65
|
|
/** |
66
|
|
* The expression value equal. |
67
|
|
*/ |
68
|
|
public abstract boolean equal(ExprValue other); |
69
|
|
} |
| | Mutations |
20 |
|
1.1 Location : compareTo Killed by : org.opensearch.sql.data.model.ExprValueCompareTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprValueCompareTest]/[method:dateValueCompare()] negated conditional → KILLED 2.2 Location : compareTo Killed by : org.opensearch.sql.data.model.ExprValueCompareTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprValueCompareTest]/[method:dateValueCompare()] negated conditional → KILLED 3.3 Location : compareTo Killed by : org.opensearch.sql.data.model.ExprValueCompareTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprValueCompareTest]/[method:dateValueCompare()] negated conditional → KILLED 4.4 Location : compareTo Killed by : org.opensearch.sql.data.model.ExprValueCompareTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprValueCompareTest]/[method:dateValueCompare()] negated conditional → KILLED
|
24 |
|
1.1 Location : compareTo Killed by : org.opensearch.sql.data.utils.ExprValueOrderingTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.utils.ExprValueOrderingTest]/[method:order_compare_value_with_compatible_number_type()] negated conditional → KILLED 2.2 Location : compareTo Killed by : org.opensearch.sql.data.utils.ExprValueOrderingTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.utils.ExprValueOrderingTest]/[method:order_compare_value_with_compatible_number_type()] negated conditional → KILLED 3.3 Location : compareTo Killed by : org.opensearch.sql.data.model.ExprValueCompareTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprValueCompareTest]/[method:dateValueCompare()] negated conditional → KILLED
|
25 |
|
1.1 Location : compareTo Killed by : org.opensearch.sql.data.model.ExprValueCompareTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprValueCompareTest]/[method:dateValueCompare()] replaced int return with 0 for org/opensearch/sql/data/model/AbstractExprValue::compareTo → KILLED
|
45 |
|
1.1 Location : equals Killed by : org.opensearch.sql.data.model.ExprNullValueTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprNullValueTest]/[method:equal()] negated conditional → KILLED
|
46 |
|
1.1 Location : equals Killed by : org.opensearch.sql.storage.bindingtuple.BindingTupleTest.[engine:junit-jupiter]/[class:org.opensearch.sql.storage.bindingtuple.BindingTupleTest]/[method:resolve_from_empty_tuple()] replaced boolean return with false for org/opensearch/sql/data/model/AbstractExprValue::equals → KILLED
|
47 |
|
1.1 Location : equals Killed by : org.opensearch.sql.data.model.ExprValueUtilsTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprValueUtilsTest]/[test-template:getValue(org.opensearch.sql.data.model.ExprValue, java.util.function.Function, java.lang.Object)]/[test-template-invocation:#9] negated conditional → KILLED
|
48 |
|
1.1 Location : equals Killed by : org.opensearch.sql.data.model.ExprCollectionValueTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprCollectionValueTest]/[method:compare_collection_with_int_object()] replaced boolean return with true for org/opensearch/sql/data/model/AbstractExprValue::equals → KILLED
|
51 |
|
1.1 Location : equals Killed by : org.opensearch.sql.data.model.ExprNullValueTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprNullValueTest]/[method:equal()] negated conditional → KILLED 2.2 Location : equals Killed by : org.opensearch.sql.data.model.ExprNullValueTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprNullValueTest]/[method:equal()] negated conditional → KILLED
|
52 |
|
1.1 Location : equals Killed by : none replaced boolean return with false for org/opensearch/sql/data/model/AbstractExprValue::equals → SURVIVED 2.2 Location : equals Killed by : org.opensearch.sql.data.model.ExprNullValueTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprNullValueTest]/[method:equal()] replaced boolean return with true for org/opensearch/sql/data/model/AbstractExprValue::equals → KILLED
|
53 |
|
1.1 Location : equals Killed by : org.opensearch.sql.data.model.ExprNullValueTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprNullValueTest]/[method:equal()] negated conditional → KILLED 2.2 Location : equals Killed by : org.opensearch.sql.data.model.ExprMissingValueTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprMissingValueTest]/[method:equal()] negated conditional → KILLED
|
54 |
|
1.1 Location : equals Killed by : none replaced boolean return with false for org/opensearch/sql/data/model/AbstractExprValue::equals → SURVIVED 2.2 Location : equals Killed by : org.opensearch.sql.data.model.ExprNullValueTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprNullValueTest]/[method:equal()] replaced boolean return with true for org/opensearch/sql/data/model/AbstractExprValue::equals → KILLED
|
56 |
|
1.1 Location : equals Killed by : org.opensearch.sql.data.model.ExprValueUtilsTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprValueUtilsTest]/[test-template:getValue(org.opensearch.sql.data.model.ExprValue, java.util.function.Function, java.lang.Object)]/[test-template-invocation:#9] replaced boolean return with false for org/opensearch/sql/data/model/AbstractExprValue::equals → KILLED 2.2 Location : equals Killed by : org.opensearch.sql.data.model.ExprCollectionValueTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprCollectionValueTest]/[method:collection_compare_int()] replaced boolean return with true for org/opensearch/sql/data/model/AbstractExprValue::equals → KILLED
|