Repository navigation
feat: Add java.nio.ByteBuffer support to IonSystem - #1168
Open
brandontoner wants to merge 1 commit into
Open
brandontoner wants to merge 1 commit into
brandontoner wants to merge 1 commit into
Conversation
Add ByteBuffer overloads to the three most common IonSystem entry points so callers holding NIO buffers no longer need to copy into a byte[] themselves: - IonSystem.iterate(ByteBuffer) - IonSystem.newReader(ByteBuffer) - IonSystem.singleValue(ByteBuffer) The methods are declared as interface default methods that delegate to the existing byte[] overloads, so the addition is source- and binary-compatible for external IonSystem implementors. A shared helper, _Private_ByteBufferUtils.toByteArrayConsuming, copies the buffer's readable region ([position, limit)) via a relative bulk get, which works for array-backed, direct (off-heap), and read-only buffers alike and advances position to limit (consume semantics). The reader/iterator operates over a private copy, so later buffer mutations do not affect reading. Add six FROM_BYTE_BUFFER_* constants to the ReaderMaker test enum (binary, text, direct, read-only, and sliced sub-range variants) so the shared reader suites exercise the new path, plus IonSystemByteBufferTest covering all buffer kinds, both formats, the position/limit contract, snapshot isolation, and null/EOF/multi-value error behavior.
This branch has not been deployed
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.
Issue #, if available:
None
Description of changes:
Add ByteBuffer overloads to the three most common IonSystem entry points so callers holding NIO buffers no longer need to copy into a byte[] themselves:
The methods are declared as interface default methods that delegate to the existing byte[] overloads, so the addition is source- and binary-compatible for external IonSystem implementors. A shared helper, _Private_ByteBufferUtils.toByteArrayConsuming, copies the buffer's readable region ([position, limit)) via a relative bulk get, which works for array-backed, direct (off-heap), and read-only buffers alike and advances position to limit (consume semantics). The reader/iterator operates over a private copy, so later buffer mutations do not affect reading.
Add six FROM_BYTE_BUFFER_* constants to the ReaderMaker test enum (binary, text, direct, read-only, and sliced sub-range variants) so the shared reader suites exercise the new path, plus IonSystemByteBufferTest covering all buffer kinds, both formats, the position/limit contract, snapshot isolation, and null/EOF/multi-value error behavior.
This provides the base level functionality, this could be optimized in the future to directly access the backing array where possible to improve performance.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.