* Serializes the paths & weights to a format that can be passed down to the CREATE INDEX. */
| 6885 | * Serializes the paths & weights to a format that can be passed down to the CREATE INDEX. |
| 6886 | */ |
| 6887 | static const char * |
| 6888 | SerializeWeightedPaths(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 | /* |
no test coverage detected