ExprCollectionValue.java

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
Location : value
Killed by : org.opensearch.sql.expression.aggregation.TakeAggregatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.aggregation.TakeAggregatorTest]/[method:test_take_all_missing_or_null()]
replaced return value with null for org/opensearch/sql/data/model/ExprCollectionValue::value → KILLED

36

1.1
Location : type
Killed by : org.opensearch.sql.data.model.ExprValueUtilsTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprValueUtilsTest]/[test-template:getType(org.opensearch.sql.data.model.ExprValue, org.opensearch.sql.data.type.ExprCoreType)]/[test-template-invocation:#9]
replaced return value with null for org/opensearch/sql/data/model/ExprCollectionValue::type → KILLED

41

1.1
Location : collectionValue
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 return value with Collections.emptyList for org/opensearch/sql/data/model/ExprCollectionValue::collectionValue → KILLED

46

1.1
Location : toString
Killed by : none
replaced return value with "" for org/opensearch/sql/data/model/ExprCollectionValue::toString → SURVIVED

53

1.1
Location : equal
Killed by : org.opensearch.sql.data.model.ExprCollectionValueTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprCollectionValueTest]/[method:collection_compare_int()]
negated conditional → KILLED

54

1.1
Location : equal
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/ExprCollectionValue::equal → KILLED

60

1.1
Location : equal
Killed by : org.opensearch.sql.planner.physical.ValuesOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.planner.physical.ValuesOperatorTest]/[method:iterateSingleRow()]
negated conditional → KILLED

2.2
Location : equal
Killed by : org.opensearch.sql.planner.physical.ValuesOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.planner.physical.ValuesOperatorTest]/[method:iterateSingleRow()]
negated conditional → KILLED

63

1.1
Location : equal
Killed by : org.opensearch.sql.planner.physical.ValuesOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.planner.physical.ValuesOperatorTest]/[method:iterateSingleRow()]
negated conditional → KILLED

64

1.1
Location : equal
Killed by : org.opensearch.sql.expression.operator.predicate.BinaryPredicateOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.operator.predicate.BinaryPredicateOperatorTest]/[test-template:test_notequal(org.opensearch.sql.data.model.ExprValue, org.opensearch.sql.data.model.ExprValue)]/[test-template-invocation:#18]
replaced boolean return with true for org/opensearch/sql/data/model/ExprCollectionValue::equal → KILLED

67

1.1
Location : equal
Killed by : org.opensearch.sql.data.model.ExprCollectionValueTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprCollectionValueTest]/[method:compare_collection_with_different_size()]
negated conditional → KILLED

2.2
Location : equal
Killed by : org.opensearch.sql.data.model.ExprCollectionValueTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprCollectionValueTest]/[method:compare_collection_with_different_size()]
negated conditional → KILLED

3.3
Location : equal
Killed by : org.opensearch.sql.data.model.ExprCollectionValueTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprCollectionValueTest]/[method:compare_collection_with_different_size()]
replaced boolean return with true for org/opensearch/sql/data/model/ExprCollectionValue::equal → KILLED

76

1.1
Location : compare
Killed by : org.opensearch.sql.data.utils.ExprValueOrderingTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.utils.ExprValueOrderingTest]/[method:natural_order_collection_value()]
replaced int return with 0 for org/opensearch/sql/data/model/ExprCollectionValue::compare → KILLED

81

1.1
Location : hashCode
Killed by : none
replaced int return with 0 for org/opensearch/sql/data/model/ExprCollectionValue::hashCode → SURVIVED

Active mutators

Tests examined


Report generated by PIT 1.9.0