Repository navigation
Optimize Mapper v2 binary conversions - #7401
Merged
alextwoods merged 1 commit intoSep 29, 2026
Merged
alextwoods merged 1 commit into
alextwoods merged 1 commit into
Conversation
alextwoods
approved these changes
Sep 29, 2026
alextwoods
merged commit Sep 29, 2026
af01ac3
into
feature/master/DDB-mapperv2
14 of 15 checks passed
|
This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Context
The DynamoDB low-level client uses
SdkBytesfor binary values in SDK v2, while Mapper v1 exposes binary POJO fields asByteBuffer. To preserve Mapper v1 compatibility, Mapper v2 convertsSdkBytesinto a writableByteBufferdefensive copy by default. That conversion adds allocation and copying overhead for binary-heavy payloads.This PR provides two independent opt-in alternatives. Customers can use
SdkBytesdirectly in their POJOs to avoid conversion on reads and writes, or keep their existingByteBufferfields and enable read-only mode to avoid defensive copies on reads.Native
SdkBytesfieldsMapper v2 now supports POJO fields declared as
SdkBytesorSet<SdkBytes>. Customers opt in by changing their binary POJO fields and accessors. This removes binary conversion on both reads and writes. ExistingByteBufferPOJOs remain unchanged. The benchmark compares equivalentByteBufferandSdkBytesschemas.Read-only
ByteBuffermodeCustomers retaining
ByteBufferfields can enableByteBufferReadBehavior.READ_ONLY. The mapper then returns a read-onlyByteBufferwithout creating a writable defensive copy. This remains opt-in because Mapper v1 returns writable buffers; applications that modify loaded buffers or call methods such ascompact()orarray()could otherwise break.MUTABLE_COPYremains the default. The benchmark uses the sameByteBufferschema for both configurations.Testing
BinaryConversionOptimizationsTestverifies writable defensive copies by default, read only buffers when enabled, separate table model caches, binary set behavior, and native scalar and setSdkBytesidentity.DynamoDBMapperConfigTestverifies the default and merged configuration behavior.