[JAVA-1753] Make calculating the size of a Document simpler Created: 08/Apr/15  Updated: 24/May/22  Resolved: 24/May/22

Status: Closed
Project: Java Driver
Component/s: API, BSON
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Ross Lawley Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates JAVA-1975 Add a toBson / fromBson helper to Doc... Backlog

 Description   

Currently it involves a lot of code:

BasicOutputBuffer buffer = new BasicOutputBuffer();
BsonBinaryWriter binaryWriter = new BsonBinaryWriter(buffer);
new DocumentCodec().encode(binaryWriter, document, EncoderContext.builder().build());
int bsonSize = binaryWriter.getBsonOutput().getSize();

Especially when compared to the legacy BSON way:

int bsonSize = BSON.encode(document).length;



 Comments   
Comment by Jeffrey Yemin [ 24/May/22 ]

Closing as essentially a duplicate of JAVA-1975

Generated at Thu Feb 08 08:55:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.