MCPcopy Create free account
hub / github.com/apache/mesos / precomputeResourcesContainment

Function precomputeResourcesContainment

src/common/resources_utils.cpp:482–507  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

480// schema (including itself), and the corresponding value is `true` if the key
481// contains a `mesos::Resource`, and `false` otherwise.
482static 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
510static Try<Nothing> convertResourcesImpl(

Callers 2

upgradeResourcesFunction · 0.85
downgradeResourcesFunction · 0.85

Calls 4

insertMethod · 0.80
fieldMethod · 0.80
atMethod · 0.80
containsMethod · 0.45

Tested by

no test coverage detected