BSON Binary Vector subtype#

In Libbson, we use the term Vector to refer to a data representation for compact storage of uniform elements, defined by the BSON Binary Subtype 9 - Vector specification.

Libbson includes API support for Vectors:

  • The view APIs provide an efficient way to access elements of Vector fields that reside within bson_t storage.

  • Integration between views and other Libbson features: append, array builder, iter.

  • Vectors can be converted to and from a plain BSON Array, subject to the specification’s type conversion rules.

The specification currently defines three element types, which Libbson interprets as:

  • int8: signed integer elements, equivalent to C int8_t.

  • float32: IEEE 754 floating point, 32 bits per element, least-significant byte first. After alignment and byte swapping, elements are equivalent to C float.

  • packed_bit: single-bit integer elements, packed most-significant bit first. Accessible in packed form as C uint8_t or as unpacked elements using C bool.

Vector Views#

Integration#

Array Conversion#

Additional Definitions#