Skip to content

Commit a7a23b5

Browse files
committed
simplify MergeOperator finished state
1 parent c064318 commit a7a23b5

File tree

1 file changed

+8
-18
lines changed
  • x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator

1 file changed

+8
-18
lines changed

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/MergeOperator.java

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
*/
2323
public class MergeOperator extends SourceOperator {
2424

25-
private final BlockFactory blockFactory;
26-
private boolean finished;
27-
private ListIterator<Block[]> subPlanBlocks;
28-
2925
public record MergeOperatorFactory(BlockSuppliers suppliers) implements SourceOperatorFactory {
3026
@Override
3127
public String describe() {
@@ -38,26 +34,25 @@ public SourceOperator get(DriverContext driverContext) {
3834
}
3935
}
4036

37+
private final BlockFactory blockFactory;
4138
private final BlockSuppliers suppliers;
39+
private boolean finished;
40+
private ListIterator<Block[]> subPlanBlocks;
4241

4342
public MergeOperator(BlockFactory blockFactory, BlockSuppliers suppliers) {
4443
super();
4544
this.blockFactory = blockFactory;
4645
this.suppliers = suppliers;
47-
this.finished = false;
48-
this.subPlanBlocks = null;
4946
}
5047

5148
public interface BlockSuppliers extends Supplier<List<Block[]>> {};
5249

5350
@Override
54-
public void finish() {
55-
finished = true;
56-
}
51+
public void finish() {}
5752

5853
@Override
5954
public boolean isFinished() {
60-
return finished && subPlanBlocks != null && subPlanBlocks.hasNext() == false;
55+
return finished;
6156
}
6257

6358
@Override
@@ -66,16 +61,11 @@ public Page getOutput() {
6661
subPlanBlocks = suppliers.get().listIterator();
6762
}
6863

69-
Page page = null;
70-
7164
if (subPlanBlocks.hasNext()) {
72-
page = new Page(subPlanBlocks.next());
65+
return new Page(subPlanBlocks.next());
7366
}
74-
if (page == null) {
75-
finished = true;
76-
}
77-
78-
return page;
67+
finished = true;
68+
return null;
7969
}
8070

8171
@Override

0 commit comments

Comments
 (0)