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

Removing unnecessary ByteArrayDataInput allocations by resetting inplace #14113

Merged
merged 4 commits into from
Jan 10, 2025

Conversation

jainankitk
Copy link
Contributor

Description

Resolves #14112

@@ -1324,8 +1324,12 @@ private void decompressBlock() throws IOException {
}

// Reset the buffer.
blockInput =
new ByteArrayDataInput(blockBuffer.bytes, blockBuffer.offset, blockBuffer.length);
if (blockInput == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should create the blockInput on the constructor and make it final.

Signed-off-by: Ankit Jain <[email protected]>
@@ -1149,6 +1148,8 @@ private class TermsDict extends BaseTermsEnum {
// add 7 padding bytes can help decompression run faster.
int bufferSize = entry.maxBlockLength + entry.maxTermLength + LZ4_DECOMPRESSOR_PADDING;
blockBuffer = new BytesRef(new byte[bufferSize], 0, bufferSize);
blockInput =
new ByteArrayDataInput(blockBuffer.bytes, blockBuffer.offset, blockBuffer.length);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you can initialize it without arguments.

Copy link
Contributor

@iverase iverase left a comment

Choose a reason for hiding this comment

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

looks good to me

Signed-off-by: Ankit Jain <[email protected]>
@iverase
Copy link
Contributor

iverase commented Jan 9, 2025

Could you add an entry in CHANGES.txt under the lucene 10.2 section?

Signed-off-by: Ankit Jain <[email protected]>
@iverase iverase merged commit 6f9702e into apache:main Jan 10, 2025
5 checks passed
iverase pushed a commit that referenced this pull request Jan 10, 2025
…ace (#14113)

Removing unnecessary ByteArrayDataInput allocations by resetting inplace

Signed-off-by: Ankit Jain <[email protected]>
@iverase iverase added this to the 10.2.0 milestone Jan 10, 2025
@iverase
Copy link
Contributor

iverase commented Jan 10, 2025

Thank you @jainankitk!

@jainankitk jainankitk deleted the alloc-fix branch January 10, 2025 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unnecessary ByteArrayDataInput allocations during aggregation query
2 participants