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 com.google.common.collect.ImmutableList; | |
9 | import java.util.List; | |
10 | import lombok.experimental.UtilityClass; | |
11 | import org.opensearch.sql.data.model.ExprValue; | |
12 | import org.opensearch.sql.expression.NamedExpression; | |
13 | import org.opensearch.sql.expression.aggregation.NamedAggregator; | |
14 | import org.opensearch.sql.storage.bindingtuple.BindingTuple; | |
15 | ||
16 | /** | |
17 | * Interface of {@link BindingTuple} Collector. | |
18 | */ | |
19 | public interface Collector { | |
20 | ||
21 | /** | |
22 | * Collect from {@link BindingTuple}. | |
23 | * | |
24 | * @param tuple {@link BindingTuple}. | |
25 | */ | |
26 | void collect(BindingTuple tuple); | |
27 | ||
28 | /** | |
29 | * Get Result from Collector. | |
30 | * | |
31 | * @return list of {@link ExprValue}. | |
32 | */ | |
33 | List<ExprValue> results(); | |
34 | ||
35 | /** | |
36 | * {@link Collector} tree builder. | |
37 | */ | |
38 | @UtilityClass | |
39 | class Builder { | |
40 | /** | |
41 | * build {@link Collector}. | |
42 | */ | |
43 | public static Collector build( | |
44 | NamedExpression span, List<NamedExpression> buckets, List<NamedAggregator> aggregators) { | |
45 |
2
1. build : negated conditional → KILLED 2. build : negated conditional → KILLED |
if (span == null && buckets.isEmpty()) { |
46 |
1
1. build : replaced return value with null for org/opensearch/sql/planner/physical/collector/Collector$Builder::build → KILLED |
return new MetricCollector(aggregators); |
47 |
1
1. build : negated conditional → KILLED |
} else if (span != null) { |
48 |
2
1. build : replaced return value with null for org/opensearch/sql/planner/physical/collector/Collector$Builder::build → KILLED 2. lambda$build$0 : replaced return value with null for org/opensearch/sql/planner/physical/collector/Collector$Builder::lambda$build$0 → KILLED |
return new SpanCollector(span, () -> build(null, buckets, aggregators)); |
49 | } else { | |
50 |
1
1. build : replaced return value with null for org/opensearch/sql/planner/physical/collector/Collector$Builder::build → KILLED |
return new BucketCollector( |
51 | buckets.get(0), | |
52 | () -> | |
53 |
1
1. lambda$build$1 : replaced return value with null for org/opensearch/sql/planner/physical/collector/Collector$Builder::lambda$build$1 → KILLED |
build(null, ImmutableList.copyOf(buckets.subList(1, buckets.size())), aggregators)); |
54 | } | |
55 | } | |
56 | } | |
57 | } | |
Mutations | ||
45 |
1.1 2.2 |
|
46 |
1.1 |
|
47 |
1.1 |
|
48 |
1.1 2.2 |
|
50 |
1.1 |
|
53 |
1.1 |