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

Function SerializeWeightedPaths

pg_documentdb/src/commands/create_indexes.c:6887–6913  ·  view source on GitHub ↗

* Serializes the paths & weights to a format that can be passed down to the CREATE INDEX. */

Source from the content-addressed store, hash-verified

6885 * Serializes the paths & weights to a format that can be passed down to the CREATE INDEX.
6886 */
6887static const char *
6888SerializeWeightedPaths(List *weightedPaths)
6889{
6890 if (weightedPaths == NIL)
6891 {
6892 return "";
6893 }
6894
6895 pgbson_writer topLevelWriter;
6896 PgbsonWriterInit(&topLevelWriter);
6897
6898 pgbson_writer childWriter;
6899 PgbsonWriterStartDocument(&topLevelWriter, "", 0, &childWriter);
6900
6901 ListCell *cell = NULL;
6902 foreach(cell, weightedPaths)
6903 {
6904 TextIndexWeights *weights = lfirst(cell);
6905 PgbsonWriterAppendDouble(&childWriter, weights->path, -1, weights->weight);
6906 }
6907
6908 PgbsonWriterEndDocument(&topLevelWriter, &childWriter);
6909
6910 pgbsonelement element;
6911 PgbsonToSinglePgbsonElement(PgbsonWriterGetPgbson(&topLevelWriter), &element);
6912 return BsonValueToJsonForLogging(&element.bsonValue);
6913}
6914
6915
6916/*

Callers 1

GenerateIndexExprStrFunction · 0.85

Calls 8

PgbsonWriterInitFunction · 0.85
PgbsonWriterAppendDoubleFunction · 0.85
PgbsonWriterEndDocumentFunction · 0.85
PgbsonWriterGetPgbsonFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected