Skip to content

Commit c8de545

Browse files
ES|QL: fix Page.equals() (#136266)
1 parent f74e8e4 commit c8de545

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

docs/changelog/136266.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 136266
2+
summary: Fix Page.equals()
3+
area: ES|QL
4+
type: bug
5+
issues: []

muted-tests.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -570,12 +570,6 @@ tests:
570570
- class: org.elasticsearch.xpack.esql.action.CrossClusterAsyncQueryStopIT
571571
method: testStopQueryInlineStats
572572
issue: https://github.com/elastic/elasticsearch/issues/135032
573-
- class: org.elasticsearch.xpack.esql.plan.logical.local.ImmediateLocalSupplierTests
574-
method: testEqualsAndHashcode
575-
issue: https://github.com/elastic/elasticsearch/issues/135977
576-
- class: org.elasticsearch.compute.data.BasicPageTests
577-
method: testEqualityAndHashCode
578-
issue: https://github.com/elastic/elasticsearch/issues/135990
579573
- class: org.elasticsearch.xpack.ml.integration.RegressionIT
580574
method: testAliasFields
581575
issue: https://github.com/elastic/elasticsearch/issues/135996

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/Page.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@ public boolean equals(Object o) {
200200
if (this == o) return true;
201201
if (o == null || getClass() != o.getClass()) return false;
202202
Page page = (Page) o;
203-
return positionCount == page.positionCount
204-
&& (positionCount == 0 || Arrays.equals(blocks, 0, blocks.length, page.blocks, 0, page.blocks.length));
203+
return positionCount == page.positionCount && Arrays.equals(blocks, page.blocks);
205204
}
206205

207206
@Override

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BasicPageTests.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ public void testEqualityAndHashCodeSmallInput() {
6060
);
6161
in.releaseBlocks();
6262

63+
in = new Page(blockFactory.newIntArrayVector(new int[] {}, 0).asBlock());
64+
EqualsHashCodeTestUtils.checkEqualsAndHashCode(
65+
in,
66+
page -> new Page(blockFactory.newIntArrayVector(new int[] {}, 0).asBlock()),
67+
page -> new Page(
68+
blockFactory.newIntArrayVector(new int[] {}, 0).asBlock(),
69+
blockFactory.newIntArrayVector(new int[] {}, 0).asBlock()
70+
),
71+
Page::releaseBlocks
72+
);
73+
in.releaseBlocks();
74+
6375
in = new Page(blockFactory.newIntArrayVector(new int[] {}, 0).asBlock());
6476
EqualsHashCodeTestUtils.checkEqualsAndHashCode(
6577
in,
@@ -136,10 +148,10 @@ public void testEqualityAndHashCode() throws IOException {
136148
Block block = page.getBlock(blockIndex);
137149
blocks[blockIndex] = block.elementType()
138150
.newBlockBuilder(positions, TestBlockFactory.getNonBreakingInstance())
139-
.copyFrom(block, 0, page.getPositionCount() - 1)
151+
.copyFrom(block, 0, positions)
140152
.build();
141153
}
142-
return new Page(blocks);
154+
return new Page(positions, blocks);
143155
};
144156

145157
int positions = randomIntBetween(0, 512);

0 commit comments

Comments
 (0)