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

Function DbStatsCoordinator

pg_documentdb/src/commands/db_stats.c:240–264  ·  view source on GitHub ↗

* The core logic for dbStats on the entry point function * i.e. the Coordinator of the dbStats. * This function simply calls the "worker" dbStats against * all available nodes, and then aggregates/merges the results into * the necessary wire protocol format. */

Source from the content-addressed store, hash-verified

238 * the necessary wire protocol format.
239 */
240static pgbson *
241DbStatsCoordinator(Datum databaseName, int32 scale)
242{
243 if (scale < 1)
244 {
245 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_LOCATION51024), errmsg(
246 "scale has to be > 0")));
247 }
248
249 StringInfo namespaceString = makeStringInfo();
250
251 appendStringInfo(namespaceString, "%.*s",
252 (int) VARSIZE_ANY_EXHDR(databaseName),
253 (char *) VARDATA_ANY(databaseName));
254
255 DbStatsResult result = { 0 };
256 result.db = namespaceString->data;
257 result.scaleFactor = scale;
258 result.ok = 1;
259
260 BuildResultData(databaseName, &result, scale);
261 pgbson *response = BuildResponseMessage(&result);
262
263 return response;
264}
265
266
267/*

Callers 1

command_db_statsFunction · 0.85

Calls 2

BuildResultDataFunction · 0.70
BuildResponseMessageFunction · 0.70

Tested by

no test coverage detected