* Merges the bloat stats from all the workers into a single * CollectionBloatStats object. */
| 183 | * CollectionBloatStats object. |
| 184 | */ |
| 185 | static CollectionBloatStats |
| 186 | MergeBloatStatsBsons(List *workerBsons) |
| 187 | { |
| 188 | CollectionBloatStats bloatStats; |
| 189 | memset(&bloatStats, 0, sizeof(CollectionBloatStats)); |
| 190 | bloatStats.nullStats = true; |
| 191 | |
| 192 | ListCell *workerCell; |
| 193 | foreach(workerCell, workerBsons) |
| 194 | { |
| 195 | pgbson *workerBson = lfirst(workerCell); |
| 196 | bson_iter_t iter; |
| 197 | PgbsonInitIterator(workerBson, &iter); |
| 198 | while (bson_iter_next(&iter)) |
| 199 | { |
| 200 | /* Non-Empty stats, reset nullStats */ |
| 201 | bloatStats.nullStats = false; |
| 202 | |
| 203 | const char *key = bson_iter_key(&iter); |
| 204 | const bson_value_t *value = bson_iter_value(&iter); |
| 205 | if (key[0] == 'b') |
| 206 | { |
| 207 | bloatStats.estimatedBloatStorage += BsonValueAsInt64(value); |
| 208 | } |
| 209 | else if (key[0] == 't') |
| 210 | { |
| 211 | bloatStats.estimatedTableStorage += BsonValueAsInt64(value); |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | return bloatStats; |
| 217 | } |
no test coverage detected