SpanCollector.java

1
/*
2
 * Copyright OpenSearch Contributors
3
 * SPDX-License-Identifier: Apache-2.0
4
 */
5
6
package org.opensearch.sql.planner.physical.collector;
7
8
import java.util.function.Supplier;
9
import org.opensearch.sql.data.model.ExprValue;
10
import org.opensearch.sql.expression.NamedExpression;
11
import org.opensearch.sql.expression.span.SpanExpression;
12
import org.opensearch.sql.storage.bindingtuple.BindingTuple;
13
14
/**
15
 * Span Collector.
16
 */
17
public class SpanCollector extends BucketCollector {
18
19
  /**
20
   * Span Expression.
21
   */
22
  private final SpanExpression spanExpr;
23
24
  /**
25
   * Rounding.
26
   */
27
  private final Rounding<?> rounding;
28
29
  /**
30
   * Constructor.
31
   */
32
  public SpanCollector(NamedExpression bucketExpr, Supplier<Collector> supplier) {
33
    super(bucketExpr, supplier);
34
    this.spanExpr = (SpanExpression) bucketExpr.getDelegated();
35
    this.rounding = Rounding.createRounding(spanExpr);
36
  }
37
38
  /**
39
   * Rounding bucket value.
40
   *
41
   * @param tuple {@link BindingTuple}.
42
   * @return {@link ExprValue}.
43
   */
44
  @Override
45
  protected ExprValue bucketKey(BindingTuple tuple) {
46 1 1. bucketKey : replaced return value with null for org/opensearch/sql/planner/physical/collector/SpanCollector::bucketKey → KILLED
    return rounding.round(spanExpr.getField().valueOf(tuple));
47
  }
48
49
  /**
50
   * Allocates Buckets for building results.
51
   *
52
   * @return buckets.
53
   */
54
  @Override
55
  protected ExprValue[] allocateBuckets() {
56 1 1. allocateBuckets : replaced return value with null for org/opensearch/sql/planner/physical/collector/SpanCollector::allocateBuckets → KILLED
    return rounding.createBuckets();
57
  }
58
59
  /**
60
   * Current Bucket index in allocated buckets.
61
   *
62
   * @param value bucket key.
63
   * @return index.
64
   */
65
  @Override
66
  protected int locateBucket(ExprValue value) {
67 1 1. locateBucket : replaced int return with 0 for org/opensearch/sql/planner/physical/collector/SpanCollector::locateBucket → KILLED
    return rounding.locate(value);
68
  }
69
}

Mutations

46

1.1
Location : bucketKey
Killed by : org.opensearch.sql.planner.physical.AggregationOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.planner.physical.AggregationOperatorTest]/[method:millisecond_span()]
replaced return value with null for org/opensearch/sql/planner/physical/collector/SpanCollector::bucketKey → KILLED

56

1.1
Location : allocateBuckets
Killed by : org.opensearch.sql.planner.physical.AggregationOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.planner.physical.AggregationOperatorTest]/[method:millisecond_span()]
replaced return value with null for org/opensearch/sql/planner/physical/collector/SpanCollector::allocateBuckets → KILLED

67

1.1
Location : locateBucket
Killed by : org.opensearch.sql.planner.physical.AggregationOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.planner.physical.AggregationOperatorTest]/[method:millisecond_span()]
replaced int return with 0 for org/opensearch/sql/planner/physical/collector/SpanCollector::locateBucket → KILLED

Active mutators

Tests examined


Report generated by PIT 1.9.0