Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProjectOperator should not retain references to released blocks #105848

Merged
merged 2 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/105848.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 105848
summary: '`ProjectOperator` should not retain references to released blocks'
area: ES|QL
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public String describe() {
}

private final int[] projection;
private Block[] blocks;
private final Block[] blocks;

/**
* Creates an operator that applies the given projection, encoded as an integer list where
Expand All @@ -41,6 +41,7 @@ public String describe() {
*/
public ProjectOperator(List<Integer> projection) {
this.projection = projection.stream().mapToInt(Integer::intValue).toArray();
this.blocks = new Block[projection.size()];
}

@Override
Expand All @@ -49,11 +50,6 @@ protected Page process(Page page) {
if (blockCount == 0) {
return page;
}
if (blocks == null) {
blocks = new Block[projection.length];
}

Arrays.fill(blocks, null);
int b = 0;
for (int source : projection) {
if (source >= blockCount) {
Expand All @@ -69,7 +65,9 @@ protected Page process(Page page) {
page.releaseBlocks();
// Use positionCount explicitly to avoid re-computing - also, if the projection is empty, there may be
// no more blocks left to determine the positionCount from.
return new Page(positionCount, blocks);
Page output = new Page(positionCount, blocks);
Arrays.fill(blocks, null);
return output;
}

@Override
Expand Down