[CDRIVER-2064] Add bson_iter_init_from_data function Created: 22/Feb/17 Updated: 24/Jan/18 Resolved: 28/Feb/17 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | libbson |
| Affects Version/s: | None |
| Fix Version/s: | 1.7.0 |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | David Golden | Assignee: | A. Jesse Jiryu Davis |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
The mongocxx driver would benefit from the ability to directly initialize a bson_iter_t from a data buffer, rather than having to repetitively call bson_init_static merely to call bson_iter_init. As bson_iter_init only uses the passed bson_t to extract a buffer pointer and length, we'd like an alternative initializer for bson_iter_t that takes those directly. A PR will follow shortly. |
| Comments |
| Comment by A. Jesse Jiryu Davis [ 28/Feb/17 ] | |
|
There were good reasons not to do this. First, that future users will wonder why we don't now have bson_iter_init_find_from_data, etc. Second, that it violates the object hierarchy that organizes libbson: raw data creates bson_t creates bson_iter_t. But practicality beats purity, and the reasons for adding this function won. | |
| Comment by A. Jesse Jiryu Davis [ 28/Feb/17 ] | |
|
https://github.com/mongodb/libbson/commit/02dc4612a28041a5ca808789f2501e147ea35e6c https://github.com/mongodb/libbson/commit/b643cc3b38fcf3158a732aaf7b152ba089efa423 | |
| Comment by Hannes Magnusson [ 22/Feb/17 ] | |
|
Thanks for the context and adding the relation to | |
| Comment by David Golden [ 22/Feb/17 ] | |
|
We need this for internal optimization. We can't initialize a bson_t with bson_init_static and cache it because of the problem mentioned in I don't want to add bson_iter_init_from_data_find because I don't think those functions should ever have been combined in the first place. You're welcome to add that if you think it's important. | |
| Comment by Hannes Magnusson [ 22/Feb/17 ] | |
|
I'm skeptical about this. It seems like a helper function the app itself should be providing.
| |
| Comment by David Golden [ 22/Feb/17 ] | |