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

Fix bug with BigIntArray serialization #90142

Merged
merged 3 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,17 @@ public void writeTo(StreamOutput out) throws IOException {
}
int intSize = (int) size;
out.writeVInt(intSize * 4);
int lastPageEnd = intSize % INT_PAGE_SIZE;
nik9000 marked this conversation as resolved.
Show resolved Hide resolved
if (lastPageEnd == 0) {
for (int i = 0; i < pages.length; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: I guess you could also do for (page : pages) { here?

out.write(pages[i]);
}
return;
}
for (int i = 0; i < pages.length - 1; i++) {
out.write(pages[i]);
}
int end = intSize % INT_PAGE_SIZE;
out.write(pages[pages.length - 1], 0, end * Integer.BYTES);
out.write(pages[pages.length - 1], 0, lastPageEnd * Integer.BYTES);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import static org.hamcrest.Matchers.equalTo;

public class ReleasableBytesReferenceStreamTests extends AbstractStreamTests {
public class ReleasableBytesReferenceStreamInputTests extends AbstractStreamTests {
nik9000 marked this conversation as resolved.
Show resolved Hide resolved
private final List<ReleasableBytesReference> opened = new ArrayList<>();
private final Set<Exception> openTraces = Collections.newSetFromMap(new IdentityHashMap<>());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ public void testSmallBigIntArray() throws IOException {
}

public void testLargeBigIntArray() throws IOException {
assertBigIntArray(between(PageCacheRecycler.INT_PAGE_SIZE, 10000));
assertBigIntArray(between(PageCacheRecycler.INT_PAGE_SIZE, 5_000_000));
nik9000 marked this conversation as resolved.
Show resolved Hide resolved
}

public void testBigIntArraySizeAligned() throws IOException {
assertBigIntArray(PageCacheRecycler.INT_PAGE_SIZE * between(2, 1000));
}

private void assertBigIntArray(int size) throws IOException {
Expand Down