DenseRankFunction.java

1
/*
2
 * Copyright OpenSearch Contributors
3
 * SPDX-License-Identifier: Apache-2.0
4
 */
5
6
7
package org.opensearch.sql.expression.window.ranking;
8
9
import org.opensearch.sql.expression.function.BuiltinFunctionName;
10
import org.opensearch.sql.expression.window.frame.CurrentRowWindowFrame;
11
12
/**
13
 * Dense rank window function that assigns a rank number to each row similarly as
14
 * rank function. The difference is there is no gap between rank number assigned.
15
 */
16
public class DenseRankFunction extends RankingWindowFunction {
17
18
  public DenseRankFunction() {
19
    super(BuiltinFunctionName.DENSE_RANK.getName());
20
  }
21
22
  @Override
23
  protected int rank(CurrentRowWindowFrame frame) {
24 1 1. rank : negated conditional → KILLED
    if (frame.isNewPartition()) {
25
      rank = 1;
26
    } else {
27 1 1. rank : negated conditional → KILLED
      if (isSortFieldValueDifferent(frame)) {
28 1 1. rank : Replaced integer addition with subtraction → KILLED
        rank++;
29
      }
30
    }
31 1 1. rank : replaced int return with 0 for org/opensearch/sql/expression/window/ranking/DenseRankFunction::rank → KILLED
    return rank;
32
  }
33
34
}

Mutations

24

1.1
Location : rank
Killed by : org.opensearch.sql.expression.window.ranking.RankingWindowFunctionTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.window.ranking.RankingWindowFunctionTest]/[method:dense_rank_should_always_return_1_if_no_sort_items_defined()]
negated conditional → KILLED

27

1.1
Location : rank
Killed by : org.opensearch.sql.expression.window.ranking.RankingWindowFunctionTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.window.ranking.RankingWindowFunctionTest]/[method:dense_rank_should_always_return_1_if_no_sort_items_defined()]
negated conditional → KILLED

28

1.1
Location : rank
Killed by : org.opensearch.sql.expression.window.ranking.RankingWindowFunctionTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.window.ranking.RankingWindowFunctionTest]/[method:test_dense_rank()]
Replaced integer addition with subtraction → KILLED

31

1.1
Location : rank
Killed by : org.opensearch.sql.expression.window.ranking.RankingWindowFunctionTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.window.ranking.RankingWindowFunctionTest]/[method:dense_rank_should_always_return_1_if_no_sort_items_defined()]
replaced int return with 0 for org/opensearch/sql/expression/window/ranking/DenseRankFunction::rank → KILLED

Active mutators

Tests examined


Report generated by PIT 1.9.0