BSON_APPEND_AR...OM_VECTOR_INT8(3)

πŸ“¦
version 2.5.6 Β· 3 versions
, in epel 10

πŸ’… BSON_APPEND_AR...OM_VECTOR_INT8 πŸ’…

okay bestie, so this one lives in libbson (that's the manual name, not me being cute), and it's basically the glow-up ritual that turns a fancy Binary Vector into a boring old BSON Array. yes, we're demoting it. it's giving "graduated and got a corporate job". let's get into it ✨


✨ SYNOPSIS ✨

here's the whole vibe, copied exactly so there's zero miscommunication:

#define BSON_APPEND_ARRAY_FROM_VECTOR_INT8(b, key, view) \
   bson_append_array_from_vector_int8 (b, key, (int) strlen (key), view)

bool
bson_append_array_from_vector_int8 (bson_t *bson,
                                    const char *key,
                                    int key_length,
                                    bson_vector_int8_const_view_t view);

so you've got the cute little macro wrapper up top β€” she does the strlen for you, no thoughts head empty, iconic β€” and then the real function underneath doing the actual work. main character energy fr fr πŸŽ€


🌸 PARAMETERS 🌸

okay so every single one of these matters, don't skip:

  • bson β€” a bson_t. that's the doc you're writing into, your canvas, your little craft project πŸ’–
  • key β€” an ASCII C string with the name of the field. yes ASCII specifically. keep it simple bestie, we're not doing emoji field names here (ironic coming from me, i know 😭)
  • key_length β€” how long key is in bytes, or -1 if you want it to figure the length out with strlen(). the "-1 means figure it out yourself" is such a mood, honestly 🫢
  • view β€” a bson_vector_int8_const_view_t pointing to validated int8 BSON Binary Vector subtype data. note the word validated, okay? that's the bouncer at the club. if it's not validated, you're not getting in 🚫

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically: it converts the Vector that view is pointing at into a plain BSON Array, and writes that array into bson under the name key. that's it. that's the whole plot. no cap πŸ’…

like, the fancy vector data goes in, a regular basic-b BSON Array comes out, gets a name tag, and gets tucked into your bson document. lowkey a makeover montage. slay 🌈


⭐ RETURNS ⭐

it returns true if the operation was applied successfully. happy ending, everyone claps πŸŽ‰

but heads up β€” it fails if appending that array makes bson grow larger than INT32_MAX. like, that's the hard ceiling, and it is not budging. if you hit it, that's not a vibe check you're passing, sorry πŸ’€

fair warning bestie: INT32_MAX is the limit, and beyond it the function just fails. don't go acting surprised when the big doc says no πŸ™ˆ

πŸ‘€ SEE ALSO πŸ‘€

  • bson_array_builder_append_vector_int8_elements()

go read that one too, iykyk 🧚


πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc


2009-present, MongoDB, Inc.


and that's the whole page, no notes πŸ’œ

okay so like, tiny sign-off β€” this masterpiece brought to you by libbson, version 2.5.6, dated Oct 09, 202 (yes the date got cut off mid-number, that's just how the page renders, don't come for me 😭). drink water, validate your views, periodt. πŸ“
πŸ“¦ where this page comes from