1 | /* | |
2 | * Copyright OpenSearch Contributors | |
3 | * SPDX-License-Identifier: Apache-2.0 | |
4 | */ | |
5 | ||
6 | ||
7 | package org.opensearch.sql.planner.physical; | |
8 | ||
9 | import com.google.common.collect.ImmutableList; | |
10 | import java.util.Iterator; | |
11 | import java.util.List; | |
12 | import java.util.stream.Collectors; | |
13 | import lombok.EqualsAndHashCode; | |
14 | import lombok.Getter; | |
15 | import lombok.ToString; | |
16 | import org.opensearch.sql.data.model.ExprCollectionValue; | |
17 | import org.opensearch.sql.data.model.ExprValue; | |
18 | import org.opensearch.sql.expression.LiteralExpression; | |
19 | ||
20 | /** | |
21 | * Physical operator for Values. | |
22 | */ | |
23 | @ToString | |
24 | @EqualsAndHashCode(callSuper = false, of = "values") | |
25 | public class ValuesOperator extends PhysicalPlan { | |
26 | ||
27 | /** | |
28 | * Original values list for print and equality check. | |
29 | */ | |
30 | @Getter | |
31 | private final List<List<LiteralExpression>> values; | |
32 | ||
33 | /** | |
34 | * Values iterator. | |
35 | */ | |
36 | private final Iterator<List<LiteralExpression>> valuesIterator; | |
37 | ||
38 | public ValuesOperator(List<List<LiteralExpression>> values) { | |
39 | this.values = values; | |
40 | this.valuesIterator = values.iterator(); | |
41 | } | |
42 | ||
43 | @Override | |
44 | public <R, C> R accept(PhysicalPlanNodeVisitor<R, C> visitor, C context) { | |
45 |
1
1. accept : replaced return value with null for org/opensearch/sql/planner/physical/ValuesOperator::accept → KILLED |
return visitor.visitValues(this, context); |
46 | } | |
47 | ||
48 | @Override | |
49 | public List<PhysicalPlan> getChild() { | |
50 |
1
1. getChild : replaced return value with Collections.emptyList for org/opensearch/sql/planner/physical/ValuesOperator::getChild → SURVIVED |
return ImmutableList.of(); |
51 | } | |
52 | ||
53 | @Override | |
54 | public boolean hasNext() { | |
55 |
2
1. hasNext : replaced boolean return with false for org/opensearch/sql/planner/physical/ValuesOperator::hasNext → KILLED 2. hasNext : replaced boolean return with true for org/opensearch/sql/planner/physical/ValuesOperator::hasNext → KILLED |
return valuesIterator.hasNext(); |
56 | } | |
57 | ||
58 | @Override | |
59 | public ExprValue next() { | |
60 | List<ExprValue> values = valuesIterator.next().stream() | |
61 |
1
1. lambda$next$0 : replaced return value with null for org/opensearch/sql/planner/physical/ValuesOperator::lambda$next$0 → KILLED |
.map(expr -> expr.valueOf()) |
62 | .collect(Collectors.toList()); | |
63 |
1
1. next : replaced return value with null for org/opensearch/sql/planner/physical/ValuesOperator::next → KILLED |
return new ExprCollectionValue(values); |
64 | } | |
65 | ||
66 | } | |
Mutations | ||
45 |
1.1 |
|
50 |
1.1 |
|
55 |
1.1 2.2 |
|
61 |
1.1 |
|
63 |
1.1 |