You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mesos.apache.org by Jie Yu <yu...@gmail.com> on 2013/12/10 19:45:00 UTC

Review Request 16158: Added a min function to stout which takes two Options.

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

Review request for mesos, Benjamin Hindman, Ben Mahler, and Jiang Yan Xu.


Repository: mesos-git


Description
-------

See summary. It will be useful when you wanna keep track of the global minimal. For example:

Option<int> lowest;

foreach (int value, values) {
  lowest = min(lowest, value);
}


Diffs
-----

  3rdparty/libprocess/3rdparty/Makefile.am f9d1aed 
  3rdparty/libprocess/3rdparty/stout/Makefile.am e46e763 
  3rdparty/libprocess/3rdparty/stout/include/stout/min.hpp PRE-CREATION 
  3rdparty/libprocess/3rdparty/stout/tests/min_tests.cpp PRE-CREATION 

Diff: https://reviews.apache.org/r/16158/diff/


Testing
-------

make check


Thanks,

Jie Yu


Re: Review Request 16158: Added a min function to stout which takes two Options.

Posted by Benjamin Hindman <be...@berkeley.edu>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/16158/#review30141
-----------------------------------------------------------

Ship it!


I like the idea of putting min and max in option.hpp for now, and just adding the tests to option_tests.cpp.

- Benjamin Hindman


On Dec. 10, 2013, 6:44 p.m., Jie Yu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/16158/
> -----------------------------------------------------------
> 
> (Updated Dec. 10, 2013, 6:44 p.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Jiang Yan Xu.
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary. It will be useful when you wanna keep track of the global minimal. For example:
> 
> Option<int> lowest;
> 
> foreach (int value, values) {
>   lowest = min(lowest, value);
> }
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/Makefile.am f9d1aed 
>   3rdparty/libprocess/3rdparty/stout/Makefile.am e46e763 
>   3rdparty/libprocess/3rdparty/stout/include/stout/min.hpp PRE-CREATION 
>   3rdparty/libprocess/3rdparty/stout/tests/min_tests.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/16158/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Jie Yu
> 
>


Re: Review Request 16158: Added min/max functions to stout which take two Options.

Posted by Benjamin Hindman <be...@berkeley.edu>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/16158/#review30158
-----------------------------------------------------------

Ship it!


Ship It!

- Benjamin Hindman


On Dec. 11, 2013, 12:26 a.m., Jie Yu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/16158/
> -----------------------------------------------------------
> 
> (Updated Dec. 11, 2013, 12:26 a.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Jiang Yan Xu.
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary. It will be useful when you wanna keep track of the global min (or max). For example:
> 
> Option<int> lowest;
> 
> foreach (int value, values) {
>   lowest = min(lowest, value);
> }
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/Makefile.am f9d1aed 
>   3rdparty/libprocess/3rdparty/stout/Makefile.am 3e22851 
>   3rdparty/libprocess/3rdparty/stout/include/stout/option.hpp 42b75a5 
>   3rdparty/libprocess/3rdparty/stout/tests/option_tests.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/16158/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Jie Yu
> 
>


Re: Review Request 16158: Added min/max functions to stout which take two Options.

Posted by Jie Yu <yu...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/16158/
-----------------------------------------------------------

(Updated Dec. 11, 2013, 12:26 a.m.)


Review request for mesos, Benjamin Hindman, Ben Mahler, and Jiang Yan Xu.


Changes
-------

BenM's comments. Added max as well.


Summary (updated)
-----------------

Added min/max functions to stout which take two Options.


Repository: mesos-git


Description (updated)
-------

See summary. It will be useful when you wanna keep track of the global min (or max). For example:

Option<int> lowest;

foreach (int value, values) {
  lowest = min(lowest, value);
}


Diffs (updated)
-----

  3rdparty/libprocess/3rdparty/Makefile.am f9d1aed 
  3rdparty/libprocess/3rdparty/stout/Makefile.am 3e22851 
  3rdparty/libprocess/3rdparty/stout/include/stout/option.hpp 42b75a5 
  3rdparty/libprocess/3rdparty/stout/tests/option_tests.cpp PRE-CREATION 

Diff: https://reviews.apache.org/r/16158/diff/


Testing
-------

make check


Thanks,

Jie Yu


Re: Review Request 16158: Added a min function to stout which takes two Options.

Posted by Jie Yu <yu...@gmail.com>.

> On Dec. 10, 2013, 6:49 p.m., Ben Mahler wrote:
> > Is the alternative just one additional line of code?
> > 
> > Option<int> lowest;
> > 
> > foreach (int value, values) {
> >   if (lowest.isNone() || value < lowest.get()) {
> >     lowest = value;
> >   }
> > }

Yeah, but I think "lowest = min(lowest, value);" is more obvious (w.r.t. expressing my intention) and easier to read. What do you think?


- Jie


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


On Dec. 10, 2013, 6:44 p.m., Jie Yu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/16158/
> -----------------------------------------------------------
> 
> (Updated Dec. 10, 2013, 6:44 p.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Jiang Yan Xu.
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary. It will be useful when you wanna keep track of the global minimal. For example:
> 
> Option<int> lowest;
> 
> foreach (int value, values) {
>   lowest = min(lowest, value);
> }
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/Makefile.am f9d1aed 
>   3rdparty/libprocess/3rdparty/stout/Makefile.am e46e763 
>   3rdparty/libprocess/3rdparty/stout/include/stout/min.hpp PRE-CREATION 
>   3rdparty/libprocess/3rdparty/stout/tests/min_tests.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/16158/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Jie Yu
> 
>


Re: Review Request 16158: Added a min function to stout which takes two Options.

Posted by Jie Yu <yu...@gmail.com>.

> On Dec. 10, 2013, 6:49 p.m., Ben Mahler wrote:
> > Is the alternative just one additional line of code?
> > 
> > Option<int> lowest;
> > 
> > foreach (int value, values) {
> >   if (lowest.isNone() || value < lowest.get()) {
> >     lowest = value;
> >   }
> > }
> 
> Jie Yu wrote:
>     Yeah, but I think "lowest = min(lowest, value);" is more obvious (w.r.t. expressing my intention) and easier to read. What do you think?
> 
> Ben Mahler wrote:
>     I agree it is more clear, but my concern here is mostly around overloading <algorithm> functions for our datatypes. If we wrap std::min, why not wrap std::max, std::sort, and many other things from <algorithm>? Is there a large benefit?

std::max will be in a separate review.


- Jie


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


On Dec. 10, 2013, 6:44 p.m., Jie Yu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/16158/
> -----------------------------------------------------------
> 
> (Updated Dec. 10, 2013, 6:44 p.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Jiang Yan Xu.
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary. It will be useful when you wanna keep track of the global minimal. For example:
> 
> Option<int> lowest;
> 
> foreach (int value, values) {
>   lowest = min(lowest, value);
> }
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/Makefile.am f9d1aed 
>   3rdparty/libprocess/3rdparty/stout/Makefile.am e46e763 
>   3rdparty/libprocess/3rdparty/stout/include/stout/min.hpp PRE-CREATION 
>   3rdparty/libprocess/3rdparty/stout/tests/min_tests.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/16158/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Jie Yu
> 
>


Re: Review Request 16158: Added a min function to stout which takes two Options.

Posted by Ben Mahler <be...@gmail.com>.

> On Dec. 10, 2013, 6:49 p.m., Ben Mahler wrote:
> > Is the alternative just one additional line of code?
> > 
> > Option<int> lowest;
> > 
> > foreach (int value, values) {
> >   if (lowest.isNone() || value < lowest.get()) {
> >     lowest = value;
> >   }
> > }
> 
> Jie Yu wrote:
>     Yeah, but I think "lowest = min(lowest, value);" is more obvious (w.r.t. expressing my intention) and easier to read. What do you think?
> 
> Ben Mahler wrote:
>     I agree it is more clear, but my concern here is mostly around overloading <algorithm> functions for our datatypes. If we wrap std::min, why not wrap std::max, std::sort, and many other things from <algorithm>? Is there a large benefit?
> 
> Jie Yu wrote:
>     std::max will be in a separate review.

Ok, perhaps this should live in stout/algorithm.hpp? Or, it seems better to place it in option.hpp and move it out if we find that we're wrapping <algorithm> functions for things other than Options..


- Ben


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


On Dec. 10, 2013, 6:44 p.m., Jie Yu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/16158/
> -----------------------------------------------------------
> 
> (Updated Dec. 10, 2013, 6:44 p.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Jiang Yan Xu.
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary. It will be useful when you wanna keep track of the global minimal. For example:
> 
> Option<int> lowest;
> 
> foreach (int value, values) {
>   lowest = min(lowest, value);
> }
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/Makefile.am f9d1aed 
>   3rdparty/libprocess/3rdparty/stout/Makefile.am e46e763 
>   3rdparty/libprocess/3rdparty/stout/include/stout/min.hpp PRE-CREATION 
>   3rdparty/libprocess/3rdparty/stout/tests/min_tests.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/16158/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Jie Yu
> 
>


Re: Review Request 16158: Added a min function to stout which takes two Options.

Posted by Ben Mahler <be...@gmail.com>.

> On Dec. 10, 2013, 6:49 p.m., Ben Mahler wrote:
> > Is the alternative just one additional line of code?
> > 
> > Option<int> lowest;
> > 
> > foreach (int value, values) {
> >   if (lowest.isNone() || value < lowest.get()) {
> >     lowest = value;
> >   }
> > }
> 
> Jie Yu wrote:
>     Yeah, but I think "lowest = min(lowest, value);" is more obvious (w.r.t. expressing my intention) and easier to read. What do you think?

I agree it is more clear, but my concern here is mostly around overloading <algorithm> functions for our datatypes. If we wrap std::min, why not wrap std::max, std::sort, and many other things from <algorithm>? Is there a large benefit?


- Ben


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


On Dec. 10, 2013, 6:44 p.m., Jie Yu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/16158/
> -----------------------------------------------------------
> 
> (Updated Dec. 10, 2013, 6:44 p.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Jiang Yan Xu.
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary. It will be useful when you wanna keep track of the global minimal. For example:
> 
> Option<int> lowest;
> 
> foreach (int value, values) {
>   lowest = min(lowest, value);
> }
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/Makefile.am f9d1aed 
>   3rdparty/libprocess/3rdparty/stout/Makefile.am e46e763 
>   3rdparty/libprocess/3rdparty/stout/include/stout/min.hpp PRE-CREATION 
>   3rdparty/libprocess/3rdparty/stout/tests/min_tests.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/16158/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Jie Yu
> 
>


Re: Review Request 16158: Added a min function to stout which takes two Options.

Posted by Jie Yu <yu...@gmail.com>.
Ian, in fact, in my case, only one Option is available at a time. For
example:

class Process {
  void callback(const Option<T>& option)
  {
    // Update the minimal.
    minimal = min(minimal, option);
  }
  Option<T> minimal;
}


On Tue, Dec 10, 2013 at 11:17 AM, Ian Downes <id...@twitter.com> wrote:

> What about just supporting min of an iterable of Option<>s?
>
> On Dec 10, 2013, at 10:49 AM, "Ben Mahler" <be...@gmail.com>
> wrote:
>
> >
> > -----------------------------------------------------------
> > This is an automatically generated e-mail. To reply, visit:
> > https://reviews.apache.org/r/16158/#review30109
> > -----------------------------------------------------------
> >
> >
> > Is the alternative just one additional line of code?
> >
> > Option<int> lowest;
> >
> > foreach (int value, values) {
> >  if (lowest.isNone() || value < lowest.get()) {
> >    lowest = value;
> >  }
> > }
> >
> > - Ben Mahler
> >
> >
> > On Dec. 10, 2013, 6:44 p.m., Jie Yu wrote:
> >>
> >> -----------------------------------------------------------
> >> This is an automatically generated e-mail. To reply, visit:
> >> https://reviews.apache.org/r/16158/
> >> -----------------------------------------------------------
> >>
> >> (Updated Dec. 10, 2013, 6:44 p.m.)
> >>
> >>
> >> Review request for mesos, Benjamin Hindman, Ben Mahler, and Jiang Yan
> Xu.
> >>
> >>
> >> Repository: mesos-git
> >>
> >>
> >> Description
> >> -------
> >>
> >> See summary. It will be useful when you wanna keep track of the global
> minimal. For example:
> >>
> >> Option<int> lowest;
> >>
> >> foreach (int value, values) {
> >>  lowest = min(lowest, value);
> >> }
> >>
> >>
> >> Diffs
> >> -----
> >>
> >>  3rdparty/libprocess/3rdparty/Makefile.am f9d1aed
> >>  3rdparty/libprocess/3rdparty/stout/Makefile.am e46e763
> >>  3rdparty/libprocess/3rdparty/stout/include/stout/min.hpp PRE-CREATION
> >>  3rdparty/libprocess/3rdparty/stout/tests/min_tests.cpp PRE-CREATION
> >>
> >> Diff: https://reviews.apache.org/r/16158/diff/
> >>
> >>
> >> Testing
> >> -------
> >>
> >> make check
> >>
> >>
> >> Thanks,
> >>
> >> Jie Yu
> >>
> >>
> >
>
>

Re: Review Request 16158: Added a min function to stout which takes two Options.

Posted by Ian Downes <id...@twitter.com>.
What about just supporting min of an iterable of Option<>s?

On Dec 10, 2013, at 10:49 AM, "Ben Mahler" <be...@gmail.com> wrote:

> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/16158/#review30109
> -----------------------------------------------------------
> 
> 
> Is the alternative just one additional line of code?
> 
> Option<int> lowest;
> 
> foreach (int value, values) {
>  if (lowest.isNone() || value < lowest.get()) {
>    lowest = value;
>  }
> }
> 
> - Ben Mahler
> 
> 
> On Dec. 10, 2013, 6:44 p.m., Jie Yu wrote:
>> 
>> -----------------------------------------------------------
>> This is an automatically generated e-mail. To reply, visit:
>> https://reviews.apache.org/r/16158/
>> -----------------------------------------------------------
>> 
>> (Updated Dec. 10, 2013, 6:44 p.m.)
>> 
>> 
>> Review request for mesos, Benjamin Hindman, Ben Mahler, and Jiang Yan Xu.
>> 
>> 
>> Repository: mesos-git
>> 
>> 
>> Description
>> -------
>> 
>> See summary. It will be useful when you wanna keep track of the global minimal. For example:
>> 
>> Option<int> lowest;
>> 
>> foreach (int value, values) {
>>  lowest = min(lowest, value);
>> }
>> 
>> 
>> Diffs
>> -----
>> 
>>  3rdparty/libprocess/3rdparty/Makefile.am f9d1aed 
>>  3rdparty/libprocess/3rdparty/stout/Makefile.am e46e763 
>>  3rdparty/libprocess/3rdparty/stout/include/stout/min.hpp PRE-CREATION 
>>  3rdparty/libprocess/3rdparty/stout/tests/min_tests.cpp PRE-CREATION 
>> 
>> Diff: https://reviews.apache.org/r/16158/diff/
>> 
>> 
>> Testing
>> -------
>> 
>> make check
>> 
>> 
>> Thanks,
>> 
>> Jie Yu
>> 
>> 
> 


Re: Review Request 16158: Added a min function to stout which takes two Options.

Posted by Ben Mahler <be...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/16158/#review30109
-----------------------------------------------------------


Is the alternative just one additional line of code?

Option<int> lowest;

foreach (int value, values) {
  if (lowest.isNone() || value < lowest.get()) {
    lowest = value;
  }
}

- Ben Mahler


On Dec. 10, 2013, 6:44 p.m., Jie Yu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/16158/
> -----------------------------------------------------------
> 
> (Updated Dec. 10, 2013, 6:44 p.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Jiang Yan Xu.
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary. It will be useful when you wanna keep track of the global minimal. For example:
> 
> Option<int> lowest;
> 
> foreach (int value, values) {
>   lowest = min(lowest, value);
> }
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/Makefile.am f9d1aed 
>   3rdparty/libprocess/3rdparty/stout/Makefile.am e46e763 
>   3rdparty/libprocess/3rdparty/stout/include/stout/min.hpp PRE-CREATION 
>   3rdparty/libprocess/3rdparty/stout/tests/min_tests.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/16158/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Jie Yu
> 
>