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

Function BuildEmptyResponseMessage

pg_documentdb/src/commands/coll_stats.c:1006–1029  ·  view source on GitHub ↗

* BuildEmptyResponseMessage func builds pgbson response for collStats() when * the provided collection is not present */

Source from the content-addressed store, hash-verified

1004 * the provided collection is not present
1005 */
1006static pgbson *
1007BuildEmptyResponseMessage(CollStatsResult *result)
1008{
1009 pgbson_writer writer;
1010 PgbsonWriterInit(&writer);
1011
1012 /*
1013 * Note: For empty collections, the response includes only a subset of fields,
1014 * and the order of fields may differ from the response for non-empty collections.
1015 * Values are written as Int32 since empty collections will always fit within this range.
1016 */
1017 PgbsonWriterAppendUtf8(&writer, "ns", 2, result->ns);
1018 PgbsonWriterAppendInt32(&writer, "size", 4, 0);
1019 PgbsonWriterAppendInt32(&writer, "count", 5, 0);
1020 PgbsonWriterAppendInt32(&writer, "storageSize", 11, 0);
1021 PgbsonWriterAppendInt32(&writer, "totalSize", 9, 0);
1022 PgbsonWriterAppendInt32(&writer, "nindexes", 8, 0);
1023 PgbsonWriterAppendInt32(&writer, "totalIndexSize", 14, 0);
1024 PgbsonWriterAppendDocument(&writer, "indexSizes", 10, PgbsonInitEmpty());
1025 PgbsonWriterAppendInt32(&writer, "scaleFactor", 11, result->scaleFactor);
1026 PgbsonWriterAppendInt32(&writer, "ok", 2, result->ok);
1027
1028 return PgbsonWriterGetPgbson(&writer);
1029}
1030
1031
1032/*

Callers 1

CollStatsCoordinatorFunction · 0.85

Calls 6

PgbsonWriterInitFunction · 0.85
PgbsonWriterAppendUtf8Function · 0.85
PgbsonWriterAppendInt32Function · 0.85
PgbsonInitEmptyFunction · 0.85
PgbsonWriterGetPgbsonFunction · 0.85

Tested by

no test coverage detected