Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CXX-3077 BSON Binary Vector accessor, sub_binary builder #1356

Open
wants to merge 81 commits into
base: master
Choose a base branch
from

Conversation

mdbmes
Copy link
Contributor

@mdbmes mdbmes commented Mar 20, 2025

This is a basic implementation of CXX-3077, adding bsoncxx support for the BSON Binary Vector specification.

The main contribution in this PR is to add the bsoncxx::vector namespace, and especially the bsoncxx::vector::accessor template. A vector accessor can wrap any validated b_binary value as read-only, or a mutable accessor can be obtained during append.

General binary items can now be created and edited in-place during an append, using a new sub_binary basic builder.

Bumps the Libmongoc version to an unreleased pre-2.0.0 snapshot, to get access to new Libbson features: bson_append_binary_uninit, bson_vector_*_const_view_init, and bson_vector_*_binary_data_length. Validation for existing and newly allocated vectors has been delegated to Libbson, to reuse as much of its testing as possible. The actual vector accessor template in bsoncxx has been implemented in a way similar to Libbson's vector views, but without a direct dependency.

This implementation is currently less comprehensive than the Libbson implementation for BSON Binary Vector. No support is included for conversion between BSON arrays and BSON vectors, and there are no functions for bulk element conversion. Instead, a standard iterator interface allows access to individual elements or element ranges.

The spec includes JSON tests that are similar to bson_corpus. As with bsoncxx's approach to bson_corpus, this PR chooses to delegate those tests to the underlying Libbson implementation.

@mdbmes mdbmes requested review from kevinAlbs and eramongodb March 21, 2025 03:27
Copy link
Contributor Author

@mdbmes mdbmes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the great suggestions.

mdbmes and others added 18 commits March 26, 2025 14:31
…binary-fwd.hpp

Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
…d.hpp

Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
….hpp

Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
@mdbmes mdbmes requested a review from eramongodb March 27, 2025 06:59
Copy link
Collaborator

@eramongodb eramongodb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestions remaining; otherwise, LGTM!

mdbmes and others added 8 commits March 27, 2025 09:52
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
@mdbmes mdbmes changed the title CXX-3077 BSON Binary Vector views, sub_binary builder CXX-3077 BSON Binary Vector accessors, sub_binary builder Mar 28, 2025
@mdbmes mdbmes changed the title CXX-3077 BSON Binary Vector accessors, sub_binary builder CXX-3077 BSON Binary Vector accessor, sub_binary builder Mar 28, 2025
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.

2 participants