Skip to content

Optimize RawBsonDocument encode and decode #1913

Draft
vbabanin wants to merge 1 commit intomongodb:mainfrom
vbabanin:JAVA-6133
Draft

Optimize RawBsonDocument encode and decode #1913
vbabanin wants to merge 1 commit intomongodb:mainfrom
vbabanin:JAVA-6133

Conversation

@vbabanin
Copy link
Member

@vbabanin vbabanin commented Mar 17, 2026

  • Add BsonWriter.pipe(byte[], int, int) with BsonBinaryWriter override to write raw BSON bytes directly to the output, avoiding intermediate object allocation on the encode path
  • Add BsonInput.pipe(BsonOutput, int) to remove the temporary byte[] copy in BsonBinaryWriter.pipeDocument() on both encode and decode paths
  • Add public getByteBacking(), getByteOffset(), getByteLength() on RawBsonDocument to expose the backing byte array

//TODO unit/integration/perf tests

JAVA-6133

…e allocations

- Add BsonWriter.pipe(byte[], int, int) with BsonBinaryWriter override to write raw BSON bytes directly to the output, avoiding intermediate object allocation on the encode path
- Add BsonInput.pipe(BsonOutput, int) to remove the temporary byte[] copy in BsonBinaryWriter.pipeDocument() on both encode and decode paths
- Add public getByteBacking(), getByteOffset(), getByteLength() on RawBsonDocument to expose the backing byte array

JAVA-6133
@vbabanin vbabanin self-assigned this Mar 17, 2026
@vbabanin vbabanin changed the title Optimize RawBsonDocument encode and decode by eliminating intermediat… Optimize RawBsonDocument encode and decode Mar 17, 2026
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.

1 participant