FilterOperator.java

1
/*
2
 * Copyright OpenSearch Contributors
3
 * SPDX-License-Identifier: Apache-2.0
4
 */
5
6
package org.opensearch.sql.planner.physical;
7
8
import java.util.Collections;
9
import java.util.List;
10
import lombok.EqualsAndHashCode;
11
import lombok.Getter;
12
import lombok.RequiredArgsConstructor;
13
import lombok.ToString;
14
import org.opensearch.sql.data.model.ExprValue;
15
import org.opensearch.sql.expression.Expression;
16
import org.opensearch.sql.expression.operator.predicate.BinaryPredicateOperator;
17
import org.opensearch.sql.storage.bindingtuple.BindingTuple;
18
19
/**
20
 * The Filter operator use the conditions to evaluate the input {@link BindingTuple}.
21
 * The Filter operator only return the results that evaluated to true.
22
 * The NULL and MISSING are handled by the logic defined in {@link BinaryPredicateOperator}.
23
 */
24
@EqualsAndHashCode(callSuper = false)
25
@ToString
26
@RequiredArgsConstructor
27
public class FilterOperator extends PhysicalPlan {
28
  @Getter
29
  private final PhysicalPlan input;
30
  @Getter
31
  private final Expression conditions;
32
  @ToString.Exclude private ExprValue next = null;
33
34
  @Override
35
  public <R, C> R accept(PhysicalPlanNodeVisitor<R, C> visitor, C context) {
36 1 1. accept : replaced return value with null for org/opensearch/sql/planner/physical/FilterOperator::accept → KILLED
    return visitor.visitFilter(this, context);
37
  }
38
39
  @Override
40
  public List<PhysicalPlan> getChild() {
41 1 1. getChild : replaced return value with Collections.emptyList for org/opensearch/sql/planner/physical/FilterOperator::getChild → KILLED
    return Collections.singletonList(input);
42
  }
43
44
  @Override
45
  public boolean hasNext() {
46 1 1. hasNext : negated conditional → KILLED
    while (input.hasNext()) {
47
      ExprValue inputValue = input.next();
48
      ExprValue exprValue = conditions.valueOf(inputValue.bindingTuples());
49 3 1. hasNext : negated conditional → KILLED
2. hasNext : negated conditional → KILLED
3. hasNext : negated conditional → KILLED
      if (!(exprValue.isNull() || exprValue.isMissing()) && (exprValue.booleanValue())) {
50
        next = inputValue;
51 1 1. hasNext : replaced boolean return with false for org/opensearch/sql/planner/physical/FilterOperator::hasNext → KILLED
        return true;
52
      }
53
    }
54 1 1. hasNext : replaced boolean return with true for org/opensearch/sql/planner/physical/FilterOperator::hasNext → KILLED
    return false;
55
  }
56
57
  @Override
58
  public ExprValue next() {
59 1 1. next : replaced return value with null for org/opensearch/sql/planner/physical/FilterOperator::next → KILLED
    return next;
60
  }
61
}

Mutations

36

1.1
Location : accept
Killed by : org.opensearch.sql.executor.ExplainTest.[engine:junit-jupiter]/[class:org.opensearch.sql.executor.ExplainTest]/[method:can_explain_project_filter_table_scan()]
replaced return value with null for org/opensearch/sql/planner/physical/FilterOperator::accept → KILLED

41

1.1
Location : getChild
Killed by : org.opensearch.sql.executor.ExplainTest.[engine:junit-jupiter]/[class:org.opensearch.sql.executor.ExplainTest]/[method:can_explain_project_filter_table_scan()]
replaced return value with Collections.emptyList for org/opensearch/sql/planner/physical/FilterOperator::getChild → KILLED

46

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

49

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

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

3.3
Location : hasNext
Killed by : org.opensearch.sql.planner.physical.FilterOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.planner.physical.FilterOperatorTest]/[method:filterTest()]
negated conditional → KILLED

51

1.1
Location : hasNext
Killed by : org.opensearch.sql.planner.physical.FilterOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.planner.physical.FilterOperatorTest]/[method:filterTest()]
replaced boolean return with false for org/opensearch/sql/planner/physical/FilterOperator::hasNext → KILLED

54

1.1
Location : hasNext
Killed by : org.opensearch.sql.planner.physical.FilterOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.planner.physical.FilterOperatorTest]/[method:nullValueShouldBeenIgnored()]
replaced boolean return with true for org/opensearch/sql/planner/physical/FilterOperator::hasNext → KILLED

59

1.1
Location : next
Killed by : org.opensearch.sql.planner.physical.FilterOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.planner.physical.FilterOperatorTest]/[method:filterTest()]
replaced return value with null for org/opensearch/sql/planner/physical/FilterOperator::next → KILLED

Active mutators

Tests examined


Report generated by PIT 1.9.0