Given a protobuf descriptor `descriptor`, recursively populates the provided `result` where the keys are the message descriptors within `descriptor`'s schema (including itself), and the corresponding value is `true` if the key contains a `mesos::Resource`, and `false` otherwise.
| 480 | // schema (including itself), and the corresponding value is `true` if the key |
| 481 | // contains a `mesos::Resource`, and `false` otherwise. |
| 482 | static void precomputeResourcesContainment( |
| 483 | const Descriptor* descriptor, |
| 484 | hashmap<const Descriptor*, bool>* result) |
| 485 | { |
| 486 | CHECK_NOTNULL(descriptor); |
| 487 | CHECK_NOTNULL(result); |
| 488 | |
| 489 | if (result->contains(descriptor)) { |
| 490 | return; |
| 491 | } |
| 492 | |
| 493 | if (descriptor == mesos::Resource::descriptor()) { |
| 494 | result->insert({descriptor, true}); |
| 495 | } |
| 496 | |
| 497 | result->insert({descriptor, false}); |
| 498 | for (int i = 0; i < descriptor->field_count(); ++i) { |
| 499 | // `message_type()` returns `nullptr` if the field is not a message type. |
| 500 | const Descriptor* messageDescriptor = descriptor->field(i)->message_type(); |
| 501 | if (messageDescriptor == nullptr) { |
| 502 | continue; |
| 503 | } |
| 504 | precomputeResourcesContainment(messageDescriptor, result); |
| 505 | result->at(descriptor) |= result->at(messageDescriptor); |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | |
| 510 | static Try<Nothing> convertResourcesImpl( |
no test coverage detected