Skip to content

GH-3767: Make PageReader AutoCloseable - #3768

Open
abstractdog wants to merge 1 commit into
apache:masterfrom
abstractdog:closable-pagereader
Open

GH-3767: Make PageReader AutoCloseable#3768
abstractdog wants to merge 1 commit into
apache:masterfrom
abstractdog:closable-pagereader

Conversation

@abstractdog

Copy link
Copy Markdown
Contributor

Rationale for this change

PageReader implementations can own resources — ColumnChunkPageReader owns decompression / decryption scratch buffers registered on a ByteBufferReleaser — but the interface has no standard teardown method. Today ColumnChunkPageReadStore.close() reaches into the concrete class through a package-private releaseBuffers() call. Alternative PageReader implementations have no idiomatic way to declare that they own resources.

What changes are included in this PR?

  • PageReader now extends AutoCloseable with a default no-op close().
  • ColumnChunkPageReader.releaseBuffers() is renamed to close().
  • ColumnChunkPageReadStore.close() hands its readers to AutoCloseables.uncheckedClose(...) directly instead of through a reader::releaseBuffers lambda.

Are these changes tested?

Yes — covered by the existing TestColumnChunkPageReadStore suite, which exercises the store's close() 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 PageReader implementations inherit the no-op default close(). Narrowing the throws clause from Exception to nothing is a legal covariant refinement.

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 Fokko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Love it @abstractdog. For the review, I've checked, there are no classes in PageReader that carry any resources.

@abstractdog

Copy link
Copy Markdown
Contributor Author

Love it @abstractdog. For the review, I've checked, there are no classes in PageReader that carry any resources.

yay, thanks for the fast review!!

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.

2 participants