MCPcopy Create free account
hub / github.com/documentdb/documentdb / PgbsonArrayWriterWriteDocument

Function PgbsonArrayWriterWriteDocument

pg_documentdb_core/src/io/pgbson.c:1377–1396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1375 * Writes a bson document to a nested array at the current index.
1376 */
1377pgbson_require_alignment() void
1378PgbsonArrayWriterWriteDocument(pgbson_array_writer *writer,
1379 const pgbson *bson)
1380{
1381 bson_t rightBson;
1382 bson_init_static(&rightBson, (const uint8_t *) VARDATA_ANY(bson),
1383 (uint32_t) VARSIZE_ANY_EXHDR(bson));
1384
1385 char buffer[20];
1386 const char *key;
1387 uint32_t keyLength = bson_uint32_to_string(writer->index, &key, buffer,
1388 sizeof buffer);
1389 if (!bson_append_document(&(writer->innerBson), key, keyLength, &rightBson))
1390 {
1391 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_BADVALUE),
1392 errmsg("adding document: failed due to document "
1393 "being too large")));
1394 }
1395 writer->index++;
1396}
1397
1398
1399/*

Calls

no outgoing calls

Tested by

no test coverage detected