GH-3767: Make PageReader AutoCloseable - #3768
Open
abstractdog wants to merge 1 commit into
Open
Conversation
Widen PageReader to extend AutoCloseable with a default no-op close(), so implementations that own resources can release them through the standard try-with-resources / AutoCloseables idiom rather than a bespoke method. Existing implementations remain source- and binary-compatible. Rename ColumnChunkPageReader.releaseBuffers() to close() and let the enclosing ColumnChunkPageReadStore.close() hand its readers to AutoCloseables.uncheckedClose() directly.
Fokko
approved these changes
Sep 4, 2026
Fokko
left a comment
Contributor
There was a problem hiding this comment.
Love it @abstractdog. For the review, I've checked, there are no classes in PageReader that carry any resources.
Contributor
Author
yay, thanks for the fast review!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
PageReaderimplementations can own resources —ColumnChunkPageReaderowns decompression / decryption scratch buffers registered on aByteBufferReleaser— but the interface has no standard teardown method. TodayColumnChunkPageReadStore.close()reaches into the concrete class through a package-privatereleaseBuffers()call. AlternativePageReaderimplementations have no idiomatic way to declare that they own resources.What changes are included in this PR?
PageReadernow extendsAutoCloseablewith a default no-opclose().ColumnChunkPageReader.releaseBuffers()is renamed toclose().ColumnChunkPageReadStore.close()hands its readers toAutoCloseables.uncheckedClose(...)directly instead of through areader::releaseBufferslambda.Are these changes tested?
Yes — covered by the existing
TestColumnChunkPageReadStoresuite, which exercises the store'sclose()path (including reader-throws and releaser-throws cases). No new tests are needed since behaviour is unchanged.Are there any user-facing changes?
No behavioural change. Source- and binary-compatible: existing
PageReaderimplementations inherit the no-op defaultclose(). Narrowing thethrowsclause fromExceptionto nothing is a legal covariant refinement.