Skip to content

Commit 53f2271

Browse files
author
MaxKsyunz
committed
Merge remote-tracking branch 'upstream/feature/pagination/integ' into feature/pagination/integ
2 parents 8a2f388 + 33dcc64 commit 53f2271

File tree

32 files changed

+43
-221
lines changed

32 files changed

+43
-221
lines changed

core/src/main/java/org/opensearch/sql/executor/ExecutionEngine.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ void execute(PhysicalPlan plan, ExecutionContext context,
5454
class QueryResponse {
5555
private final Schema schema;
5656
private final List<ExprValue> results;
57-
private final long total;
5857
private final Cursor cursor;
5958
}
6059

core/src/main/java/org/opensearch/sql/planner/physical/CursorCloseOperator.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ public ExecutionEngine.Schema schema() {
4949
return new ExecutionEngine.Schema(List.of());
5050
}
5151

52-
// TODO remove
53-
@Override
54-
public long getTotalHits() {
55-
return 0;
56-
}
57-
5852
@Override
5953
public void open() {
6054
// no-op, no search should be invoked.

core/src/main/java/org/opensearch/sql/planner/physical/FilterOperator.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public class FilterOperator extends PhysicalPlan {
3232
private final Expression conditions;
3333
@ToString.Exclude
3434
private ExprValue next = null;
35-
private long totalHits = 0;
3635

3736
@Override
3837
public <R, C> R accept(PhysicalPlanNodeVisitor<R, C> visitor, C context) {
@@ -51,7 +50,6 @@ public boolean hasNext() {
5150
ExprValue exprValue = conditions.valueOf(inputValue.bindingTuples());
5251
if (!(exprValue.isNull() || exprValue.isMissing()) && (exprValue.booleanValue())) {
5352
next = inputValue;
54-
totalHits++;
5553
return true;
5654
}
5755
}
@@ -62,10 +60,4 @@ public boolean hasNext() {
6260
public ExprValue next() {
6361
return next;
6462
}
65-
66-
@Override
67-
public long getTotalHits() {
68-
// ignore `input.getTotalHits()`, because it returns wrong (unfiltered) value
69-
return totalHits;
70-
}
7163
}

core/src/main/java/org/opensearch/sql/planner/physical/NestedOperator.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ public class NestedOperator extends PhysicalPlan {
4747
@EqualsAndHashCode.Exclude
4848
private ListIterator<Map<String, ExprValue>> flattenedResult = result.listIterator();
4949

50-
private long totalHits = 0;
51-
5250
/**
5351
* Constructor for NestedOperator with list of map as arg.
5452
* @param input : PhysicalPlan input.
@@ -121,13 +119,11 @@ public ExprValue next() {
121119

122120
if (result.isEmpty()) {
123121
flattenedResult = result.listIterator();
124-
totalHits++;
125122
return new ExprTupleValue(new LinkedHashMap<>());
126123
}
127124

128125
flattenedResult = result.listIterator();
129126
}
130-
totalHits++;
131127
return new ExprTupleValue(new LinkedHashMap<>(flattenedResult.next()));
132128
}
133129

@@ -283,9 +279,4 @@ private void getNested(
283279
row, ret, currentObj);
284280
}
285281
}
286-
287-
@Override
288-
public long getTotalHits() {
289-
return totalHits;
290-
}
291282
}

core/src/main/java/org/opensearch/sql/planner/physical/PhysicalPlan.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,4 @@ public ExecutionEngine.Schema schema() {
4444
throw new IllegalStateException(String.format("[BUG] schema can been only applied to "
4545
+ "ProjectOperator, instead of %s", this.getClass().getSimpleName()));
4646
}
47-
48-
/**
49-
* Returns Total hits matched the search criteria. Note: query may return less if limited.
50-
* {@see Settings#QUERY_SIZE_LIMIT}.
51-
* Any plan which adds/removes rows to the response should overwrite it to provide valid values.
52-
*
53-
* @return Total hits matched the search criteria.
54-
*/
55-
public long getTotalHits() {
56-
return getChild().stream().mapToLong(PhysicalPlan::getTotalHits).max().orElse(0);
57-
}
5847
}

core/src/main/java/org/opensearch/sql/planner/physical/ValuesOperator.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,6 @@ public boolean hasNext() {
5656
return valuesIterator.hasNext();
5757
}
5858

59-
@Override
60-
public long getTotalHits() {
61-
// ValuesOperator used for queries without `FROM` clause, e.g. `select 1`.
62-
// Such query always returns 1 row.
63-
return 1;
64-
}
65-
6659
@Override
6760
public ExprValue next() {
6861
List<ExprValue> values = valuesIterator.next().stream()

core/src/test/java/org/opensearch/sql/executor/QueryServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Helper executeSuccess(Split split) {
133133
invocation -> {
134134
ResponseListener<ExecutionEngine.QueryResponse> listener = invocation.getArgument(2);
135135
listener.onResponse(
136-
new ExecutionEngine.QueryResponse(schema, Collections.emptyList(), 0,
136+
new ExecutionEngine.QueryResponse(schema, Collections.emptyList(),
137137
Cursor.None));
138138
return null;
139139
})

core/src/test/java/org/opensearch/sql/executor/streaming/MicroBatchStreamingExecutionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Helper executeSuccess(Long... offsets) {
170170
ResponseListener<ExecutionEngine.QueryResponse> listener =
171171
invocation.getArgument(2);
172172
listener.onResponse(
173-
new ExecutionEngine.QueryResponse(null, Collections.emptyList(), 0,
173+
new ExecutionEngine.QueryResponse(null, Collections.emptyList(),
174174
Cursor.None));
175175

176176
PlanContext planContext = invocation.getArgument(1);

core/src/test/java/org/opensearch/sql/planner/physical/CursorCloseOperatorTest.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@ public void never_hasNext() {
2727
assertFalse(plan.hasNext());
2828
}
2929

30-
// TODO remove
31-
@Test
32-
public void no_total_hits() {
33-
var plan = new CursorCloseOperator(null);
34-
assertEquals(0, plan.getTotalHits());
35-
plan.open();
36-
assertEquals(0, plan.getTotalHits());
37-
}
38-
3930
@Test
4031
public void open_is_not_propagated() {
4132
var child = mock(PhysicalPlan.class);

core/src/test/java/org/opensearch/sql/planner/physical/FilterOperatorTest.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public void filter_test() {
5050
.tupleValue(ImmutableMap
5151
.of("ip", "209.160.24.63", "action", "GET", "response", 404, "referer",
5252
"www.amazon.com"))));
53-
assertEquals(1, plan.getTotalHits());
5453
}
5554

5655
@Test
@@ -64,7 +63,6 @@ public void null_value_should_been_ignored() {
6463
DSL.equal(DSL.ref("response", INTEGER), DSL.literal(404)));
6564
List<ExprValue> result = execute(plan);
6665
assertEquals(0, result.size());
67-
assertEquals(0, plan.getTotalHits());
6866
}
6967

7068
@Test
@@ -78,21 +76,5 @@ public void missing_value_should_been_ignored() {
7876
DSL.equal(DSL.ref("response", INTEGER), DSL.literal(404)));
7977
List<ExprValue> result = execute(plan);
8078
assertEquals(0, result.size());
81-
assertEquals(0, plan.getTotalHits());
82-
}
83-
84-
@Test
85-
public void totalHits() {
86-
when(inputPlan.hasNext()).thenReturn(true, true, true, true, true, false);
87-
var answers = Stream.of(200, 240, 300, 403, 404).map(c ->
88-
new ExprTupleValue(new LinkedHashMap<>(Map.of("response", new ExprIntegerValue(c)))))
89-
.collect(Collectors.toList());
90-
when(inputPlan.next()).thenAnswer(AdditionalAnswers.returnsElementsOf(answers));
91-
92-
FilterOperator plan = new FilterOperator(inputPlan,
93-
DSL.less(DSL.ref("response", INTEGER), DSL.literal(400)));
94-
List<ExprValue> result = execute(plan);
95-
assertEquals(3, result.size());
96-
assertEquals(3, plan.getTotalHits());
9779
}
9880
}

0 commit comments

Comments
 (0)