mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin Mahler <bmah...@apache.org>
Subject Re: Review Request 70507: Enabled construction of 'ResourceQuantities' from arbitrary resources.
Date Sat, 20 Apr 2019 18:27:46 GMT

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/70507/#review214776
-----------------------------------------------------------




src/common/resource_quantities.cpp
Lines 96-116 (patched)
<https://reviews.apache.org/r/70507/#comment301034>

    Just a thought: we could avoid adding the `add()` overload:
    
    ```
      foreach (const Resource& resource, resources) {
        Value::Scalar scalar;
        
        scalar.set_value([&]() {
          switch (resource.type()) {
            case Value::SCALAR:
              return resource.scalar().value();
            case Value::SET:
              return resource.set().item_size());
            case Value::RANGES: {
              double total = 0.0;
              foreach (const Value::Range& range, resource.ranges().range()) {
                total += range.end() - range.begin() + 1;
              }
              return total;
            case Value::TEXT:
              LOG(FATAL) << "TEXT type resources are not valid";
          }  
          UNREACHABLE();
        }());
    
        add(resource.name(), scalar);
      }
    ```



src/common/resource_quantities.cpp
Lines 98-114 (patched)
<https://reviews.apache.org/r/70507/#comment301035>

    Btw, we only need the case braces when there is a variable declaration in the case


- Benjamin Mahler


On April 20, 2019, 6:14 p.m., Greg Mann wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/70507/
> -----------------------------------------------------------
> 
> (Updated April 20, 2019, 6:14 p.m.)
> 
> 
> Review request for mesos, Benno Evers, Benjamin Mahler, and Meng Zhu.
> 
> 
> Bugs: MESOS-9619
>     https://issues.apache.org/jira/browse/MESOS-9619
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> This patch adds a new static method which enables the
> construction of `ResourceQuantities` from `Resources`.
> Namely, this permits the inclusion of sets and ranges in the
> input resources used to construct `ResourceQuantities`.
> 
> 
> Diffs
> -----
> 
>   src/common/resource_quantities.hpp cbf1364b4617b7627822a24cd0c8ecf80cd9e583 
>   src/common/resource_quantities.cpp 48e89947502c1c056456f77144e62455e3745440 
>   src/tests/resource_quantities_tests.cpp 0f42479b194a2f45b6e7f411094cd28ac502c7c4 
> 
> 
> Diff: https://reviews.apache.org/r/70507/diff/3/
> 
> 
> Testing
> -------
> 
> Testing details at the end of this chain.
> 
> 
> Thanks,
> 
> Greg Mann
> 
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message