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 com.google.common.base.Objects; | |
10 | import java.util.ArrayList; | |
11 | import java.util.Iterator; | |
12 | import java.util.List; | |
13 | import java.util.stream.Collectors; | |
14 | import lombok.RequiredArgsConstructor; | |
15 | import org.opensearch.sql.data.type.ExprCoreType; | |
16 | import org.opensearch.sql.data.type.ExprType; | |
17 | ||
18 | /** | |
19 | * Expression Collection Value. | |
20 | */ | |
21 | @RequiredArgsConstructor | |
22 | public class ExprCollectionValue extends AbstractExprValue { | |
23 | private final List<ExprValue> valueList; | |
24 | ||
25 | @Override | |
26 | public Object value() { | |
27 | List<Object> results = new ArrayList<>(); | |
28 | for (ExprValue exprValue : valueList) { | |
29 | results.add(exprValue.value()); | |
30 | } | |
31 |
1
1. value : replaced return value with null for org/opensearch/sql/data/model/ExprCollectionValue::value → KILLED |
return results; |
32 | } | |
33 | ||
34 | @Override | |
35 | public ExprType type() { | |
36 |
1
1. type : replaced return value with null for org/opensearch/sql/data/model/ExprCollectionValue::type → KILLED |
return ExprCoreType.ARRAY; |
37 | } | |
38 | ||
39 | @Override | |
40 | public List<ExprValue> collectionValue() { | |
41 |
1
1. collectionValue : replaced return value with Collections.emptyList for org/opensearch/sql/data/model/ExprCollectionValue::collectionValue → KILLED |
return valueList; |
42 | } | |
43 | ||
44 | @Override | |
45 | public String toString() { | |
46 |
1
1. toString : replaced return value with "" for org/opensearch/sql/data/model/ExprCollectionValue::toString → SURVIVED |
return valueList.stream() |
47 | .map(Object::toString) | |
48 | .collect(Collectors.joining(", ", "[", "]")); | |
49 | } | |
50 | ||
51 | @Override | |
52 | public boolean equal(ExprValue o) { | |
53 |
1
1. equal : negated conditional → KILLED |
if (!(o instanceof ExprCollectionValue)) { |
54 |
1
1. equal : replaced boolean return with true for org/opensearch/sql/data/model/ExprCollectionValue::equal → KILLED |
return false; |
55 | } else { | |
56 | ExprCollectionValue other = (ExprCollectionValue) o; | |
57 | Iterator<ExprValue> thisIterator = this.valueList.iterator(); | |
58 | Iterator<ExprValue> otherIterator = other.valueList.iterator(); | |
59 | ||
60 |
2
1. equal : negated conditional → KILLED 2. equal : negated conditional → KILLED |
while (thisIterator.hasNext() && otherIterator.hasNext()) { |
61 | ExprValue thisEntry = thisIterator.next(); | |
62 | ExprValue otherEntry = otherIterator.next(); | |
63 |
1
1. equal : negated conditional → KILLED |
if (!thisEntry.equals(otherEntry)) { |
64 |
1
1. equal : replaced boolean return with true for org/opensearch/sql/data/model/ExprCollectionValue::equal → KILLED |
return false; |
65 | } | |
66 | } | |
67 |
3
1. equal : negated conditional → KILLED 2. equal : negated conditional → KILLED 3. equal : replaced boolean return with true for org/opensearch/sql/data/model/ExprCollectionValue::equal → KILLED |
return !(thisIterator.hasNext() || otherIterator.hasNext()); |
68 | } | |
69 | } | |
70 | ||
71 | /** | |
72 | * Only compare the size of the list. | |
73 | */ | |
74 | @Override | |
75 | public int compare(ExprValue other) { | |
76 |
1
1. compare : replaced int return with 0 for org/opensearch/sql/data/model/ExprCollectionValue::compare → KILLED |
return Integer.compare(valueList.size(), other.collectionValue().size()); |
77 | } | |
78 | ||
79 | @Override | |
80 | public int hashCode() { | |
81 |
1
1. hashCode : replaced int return with 0 for org/opensearch/sql/data/model/ExprCollectionValue::hashCode → SURVIVED |
return Objects.hashCode(valueList); |
82 | } | |
83 | } | |
Mutations | ||
31 |
1.1 |
|
36 |
1.1 |
|
41 |
1.1 |
|
46 |
1.1 |
|
53 |
1.1 |
|
54 |
1.1 |
|
60 |
1.1 2.2 |
|
63 |
1.1 |
|
64 |
1.1 |
|
67 |
1.1 2.2 3.3 |
|
76 |
1.1 |
|
81 |
1.1 |