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 java.time.temporal.TemporalAmount; | |
10 | import java.time.temporal.TemporalUnit; | |
11 | import lombok.RequiredArgsConstructor; | |
12 | import org.opensearch.sql.data.type.ExprCoreType; | |
13 | import org.opensearch.sql.data.type.ExprType; | |
14 | import org.opensearch.sql.exception.ExpressionEvaluationException; | |
15 | ||
16 | @RequiredArgsConstructor | |
17 | public class ExprIntervalValue extends AbstractExprValue { | |
18 | private final TemporalAmount interval; | |
19 | ||
20 | @Override | |
21 | public TemporalAmount intervalValue() { | |
22 |
1
1. intervalValue : replaced return value with null for org/opensearch/sql/data/model/ExprIntervalValue::intervalValue → KILLED |
return interval; |
23 | } | |
24 | ||
25 | @Override | |
26 | public int compare(ExprValue other) { | |
27 | TemporalAmount otherInterval = other.intervalValue(); | |
28 |
1
1. compare : negated conditional → KILLED |
if (!interval.getClass().equals(other.intervalValue().getClass())) { |
29 | throw new ExpressionEvaluationException( | |
30 | String.format("invalid to compare intervals with units %s and %s", | |
31 | unit(), ((ExprIntervalValue) other).unit())); | |
32 | } | |
33 |
1
1. compare : replaced int return with 0 for org/opensearch/sql/data/model/ExprIntervalValue::compare → KILLED |
return Long.compare( |
34 | interval.get(unit()), otherInterval.get(((ExprIntervalValue) other).unit())); | |
35 | } | |
36 | ||
37 | @Override | |
38 | public boolean equal(ExprValue other) { | |
39 |
2
1. equal : replaced boolean return with true for org/opensearch/sql/data/model/ExprIntervalValue::equal → SURVIVED 2. equal : replaced boolean return with false for org/opensearch/sql/data/model/ExprIntervalValue::equal → KILLED |
return interval.equals(other.intervalValue()); |
40 | } | |
41 | ||
42 | @Override | |
43 | public TemporalAmount value() { | |
44 |
1
1. value : replaced return value with null for org/opensearch/sql/data/model/ExprIntervalValue::value → KILLED |
return interval; |
45 | } | |
46 | ||
47 | @Override | |
48 | public ExprType type() { | |
49 |
1
1. type : replaced return value with null for org/opensearch/sql/data/model/ExprIntervalValue::type → KILLED |
return ExprCoreType.INTERVAL; |
50 | } | |
51 | ||
52 | /** | |
53 | * Util method to get temporal unit stored locally. | |
54 | */ | |
55 | public TemporalUnit unit() { | |
56 |
1
1. unit : replaced return value with null for org/opensearch/sql/data/model/ExprIntervalValue::unit → KILLED |
return interval.getUnits() |
57 | .stream() | |
58 |
2
1. lambda$unit$0 : negated conditional → KILLED 2. lambda$unit$0 : replaced boolean return with true for org/opensearch/sql/data/model/ExprIntervalValue::lambda$unit$0 → KILLED |
.filter(v -> interval.get(v) != 0) |
59 | .findAny() | |
60 | .orElse(interval.getUnits().get(0)); | |
61 | } | |
62 | } | |
Mutations | ||
22 |
1.1 |
|
28 |
1.1 |
|
33 |
1.1 |
|
39 |
1.1 2.2 |
|
44 |
1.1 |
|
49 |
1.1 |
|
56 |
1.1 |
|
58 |
1.1 2.2 |