[SERVER-2152] BSONObjBuilder and BSONArrayBuilder objects should be re-useable Created: 26/Nov/10  Updated: 29/Feb/12  Resolved: 18/Oct/11

Status: Closed
Project: Core Server
Component/s: Internal Client
Affects Version/s: 1.6.3, 1.6.4, 1.6.5, 1.7.0, 1.7.1, 1.7.2, 1.7.3
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Andrew Morrow (Inactive) Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Participants:

 Description   

While using BufBuilder, BSONObjBuilder, and BSONArrayBuilder to generate BSON in C++, it would be nice to be able to associate a pool of BSONObjBuilder and BSONArrayBuilder objects with a BufBuilder so these objects can be efficiently obtained and re-used. This is currently not possible, since there is no way to inform a BSONObjBuilder that its _offset field should be reset to the current 'len' of its underlying BufBuilder, so these objects are one and done.

BSONObjBuilder and BSONArrayBuilder should offer a method that resynchronizes the builder with the current position in the underlying BufBuilder. I haven't been able to come up with a particularly good name for this method, so I'm open to suggestions, but something like 'resynchronizeWithBufBuilder' might do. Given that this is a sort of special case method, it is probably OK for it to have a sort of ugly name.



 Comments   
Comment by Mathias Stearn [ 01/Sep/11 ]

Could you take a look at the technique used here and let as know if that meets your needs:

https://github.com/mongodb/mongo/blob/master/db/introspect.cpp#L30-41

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