You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@mesos.apache.org by Alexander Rojas <al...@mesosphere.io> on 2015/06/25 15:45:38 UTC

Review Request 35874: Added template parameters and constructors to hashset which reflex the state of hashmap

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

Review request for mesos, Bernd Mathiske, Joerg Schad, Michael Park, and Till Toenshoff.


Bugs: MESOS-2924
    https://issues.apache.org/jira/browse/MESOS-2924


Repository: mesos


Description
-------

Adds extra template parameters to hashset as well as implicit constructors from
`std::set` and a initializer list constructor.

These changes keep hashset up to date with the changes in hashmap.


Diffs
-----

  3rdparty/libprocess/3rdparty/stout/include/stout/hashset.hpp 75ed9db54dc9ab502e978f06c55a621cacb56b91 
  3rdparty/libprocess/3rdparty/stout/tests/hashset_tests.cpp 3c4b732432c0c155451d34ecd5f985318d118fe5 

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


Testing
-------

make check


Thanks,

Alexander Rojas


Re: Review Request 35874: Added template parameters and constructors to hashset to match the signature of hashmap

Posted by Michael Park <mc...@gmail.com>.

> On June 30, 2015, 11:55 p.m., Joris Van Remoortere wrote:
> > Hi Alex,
> > I just wanted to follow up on our conversation.
> > As discussed, I think it makes sense to refactor to use `std::unordered_set<>` first.
> > After that, I think you can simplify this code significantly:
> > ```
> > hashset(const std::set<Elem> &set) : std::unordered_set<Elem, Hash, Equal>(set.begin(), set.end(), std::ceil(list.size() / max_load_factor())) {}
> > 
> > hashset(std::initializer_list<Elem> list) : std::unordered_set<Elem, Hash, Equal>(list.begin(), list.end(), std::ceil(list.size() / max_load_factor())) {}
> > ```
> > 
> > The move constructor is a little trickier, let's discuss that one :-)

Hey Joris, I've filed [MESOS-3217](https://issues.apache.org/jira/browse/MESOS-3217) to capture the work involved in our transition from boost `unordered_{set,map}` and `hash` to their standard counterparts. Meanwhile, I've committed this patch to keep `hashset` and `hashmap` APIs consistent.


- Michael


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


On July 7, 2015, 8:51 a.m., Alexander Rojas wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/35874/
> -----------------------------------------------------------
> 
> (Updated July 7, 2015, 8:51 a.m.)
> 
> 
> Review request for mesos, Bernd Mathiske, Joerg Schad, Michael Park, and Till Toenshoff.
> 
> 
> Bugs: MESOS-2924
>     https://issues.apache.org/jira/browse/MESOS-2924
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Adds extra template parameters to hashset as well as implicit constructors from
> `std::set` and a initializer list constructor.
> 
> These changes keep hashset up to date with the changes in hashmap.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/stout/include/stout/hashset.hpp 75ed9db54dc9ab502e978f06c55a621cacb56b91 
>   3rdparty/libprocess/3rdparty/stout/tests/hashset_tests.cpp 3c4b732432c0c155451d34ecd5f985318d118fe5 
> 
> Diff: https://reviews.apache.org/r/35874/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Alexander Rojas
> 
>


Re: Review Request 35874: Added template parameters and constructors to hashset which reflex the state of hashmap

Posted by Joris Van Remoortere <jo...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/35874/#review89982
-----------------------------------------------------------


Hi Alex,
I just wanted to follow up on our conversation.
As discussed, I think it makes sense to refactor to use `std::unordered_set<>` first.
After that, I think you can simplify this code significantly:
```
hashset(const std::set<Elem> &set) : std::unordered_set<Elem, Hash, Equal>(set.begin(), set.end(), std::ceil(list.size() / max_load_factor())) {}

hashset(std::initializer_list<Elem> list) : std::unordered_set<Elem, Hash, Equal>(list.begin(), list.end(), std::ceil(list.size() / max_load_factor())) {}
```

The move constructor is a little trickier, let's discuss that one :-)

- Joris Van Remoortere


On June 25, 2015, 1:45 p.m., Alexander Rojas wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/35874/
> -----------------------------------------------------------
> 
> (Updated June 25, 2015, 1:45 p.m.)
> 
> 
> Review request for mesos, Bernd Mathiske, Joerg Schad, Michael Park, and Till Toenshoff.
> 
> 
> Bugs: MESOS-2924
>     https://issues.apache.org/jira/browse/MESOS-2924
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Adds extra template parameters to hashset as well as implicit constructors from
> `std::set` and a initializer list constructor.
> 
> These changes keep hashset up to date with the changes in hashmap.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/stout/include/stout/hashset.hpp 75ed9db54dc9ab502e978f06c55a621cacb56b91 
>   3rdparty/libprocess/3rdparty/stout/tests/hashset_tests.cpp 3c4b732432c0c155451d34ecd5f985318d118fe5 
> 
> Diff: https://reviews.apache.org/r/35874/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Alexander Rojas
> 
>


Re: Review Request 35874: Added template parameters and constructors to hashset which reflex the state of hashmap

Posted by Mesos ReviewBot <re...@mesos.apache.org>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/35874/#review89349
-----------------------------------------------------------


Patch looks great!

Reviews applied: [35874]

All tests passed.

- Mesos ReviewBot


On June 25, 2015, 1:45 p.m., Alexander Rojas wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/35874/
> -----------------------------------------------------------
> 
> (Updated June 25, 2015, 1:45 p.m.)
> 
> 
> Review request for mesos, Bernd Mathiske, Joerg Schad, Michael Park, and Till Toenshoff.
> 
> 
> Bugs: MESOS-2924
>     https://issues.apache.org/jira/browse/MESOS-2924
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Adds extra template parameters to hashset as well as implicit constructors from
> `std::set` and a initializer list constructor.
> 
> These changes keep hashset up to date with the changes in hashmap.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/stout/include/stout/hashset.hpp 75ed9db54dc9ab502e978f06c55a621cacb56b91 
>   3rdparty/libprocess/3rdparty/stout/tests/hashset_tests.cpp 3c4b732432c0c155451d34ecd5f985318d118fe5 
> 
> Diff: https://reviews.apache.org/r/35874/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Alexander Rojas
> 
>


Re: Review Request 35874: Added template parameters and constructors to hashset which reflex the state of hashmap

Posted by Joerg Schad <jo...@mesosphere.io>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/35874/#review89381
-----------------------------------------------------------


s/reflex/reflects

- Joerg Schad


On June 25, 2015, 1:45 p.m., Alexander Rojas wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/35874/
> -----------------------------------------------------------
> 
> (Updated June 25, 2015, 1:45 p.m.)
> 
> 
> Review request for mesos, Bernd Mathiske, Joerg Schad, Michael Park, and Till Toenshoff.
> 
> 
> Bugs: MESOS-2924
>     https://issues.apache.org/jira/browse/MESOS-2924
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Adds extra template parameters to hashset as well as implicit constructors from
> `std::set` and a initializer list constructor.
> 
> These changes keep hashset up to date with the changes in hashmap.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/stout/include/stout/hashset.hpp 75ed9db54dc9ab502e978f06c55a621cacb56b91 
>   3rdparty/libprocess/3rdparty/stout/tests/hashset_tests.cpp 3c4b732432c0c155451d34ecd5f985318d118fe5 
> 
> Diff: https://reviews.apache.org/r/35874/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Alexander Rojas
> 
>


Re: Review Request 35874: Added template parameters and constructors to hashset to match the signature of hashmap

Posted by Michael Park <mc...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/35874/#review94347
-----------------------------------------------------------

Ship it!


I'll get this committed for you with the minor changes below.


3rdparty/libprocess/3rdparty/stout/include/stout/hashset.hpp (lines 62 - 66)
<https://reviews.apache.org/r/35874/#comment148917>

    Let's omit the "Apparently a bug in the ..." part of the comment.
    ```
    // An implementation based on the move constructor of 'hashmap'
    // fails to compile on all major compilers except gcc 5.1 and up.
    // See http://stackoverflow.com/q/31051466/118750?sem=2.
    ```



3rdparty/libprocess/3rdparty/stout/include/stout/hashset.hpp (lines 67 - 71)
<https://reviews.apache.org/r/35874/#comment148921>

    Let's keep this consistent with the patterns in the other constructors.
    ```
    boost::unordered_set<Elem, Hash, Equal>::reserve(set.size());
    
    for (auto iterator = set.begin(); iterator != set.end(); ++iterator) {
      boost::unordered_set<Elem, Hash, Equal>::emplace(std::move(*iterator));
    }
    ```



3rdparty/libprocess/3rdparty/stout/include/stout/hashset.hpp (lines 120 - 121)
<https://reviews.apache.org/r/35874/#comment148919>

    2 indents after assignment operator.


- Michael Park


On July 7, 2015, 8:51 a.m., Alexander Rojas wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/35874/
> -----------------------------------------------------------
> 
> (Updated July 7, 2015, 8:51 a.m.)
> 
> 
> Review request for mesos, Bernd Mathiske, Joerg Schad, Michael Park, and Till Toenshoff.
> 
> 
> Bugs: MESOS-2924
>     https://issues.apache.org/jira/browse/MESOS-2924
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Adds extra template parameters to hashset as well as implicit constructors from
> `std::set` and a initializer list constructor.
> 
> These changes keep hashset up to date with the changes in hashmap.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/stout/include/stout/hashset.hpp 75ed9db54dc9ab502e978f06c55a621cacb56b91 
>   3rdparty/libprocess/3rdparty/stout/tests/hashset_tests.cpp 3c4b732432c0c155451d34ecd5f985318d118fe5 
> 
> Diff: https://reviews.apache.org/r/35874/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Alexander Rojas
> 
>


Re: Review Request 35874: Added template parameters and constructors to hashset to match the signature of hashmap

Posted by Alexander Rojas <al...@mesosphere.io>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/35874/
-----------------------------------------------------------

(Updated July 7, 2015, 1:51 a.m.)


Review request for mesos, Bernd Mathiske, Joerg Schad, Michael Park, and Till Toenshoff.


Changes
-------

Clearer summary.


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

Added template parameters and constructors to hashset to match the signature of hashmap


Bugs: MESOS-2924
    https://issues.apache.org/jira/browse/MESOS-2924


Repository: mesos


Description
-------

Adds extra template parameters to hashset as well as implicit constructors from
`std::set` and a initializer list constructor.

These changes keep hashset up to date with the changes in hashmap.


Diffs
-----

  3rdparty/libprocess/3rdparty/stout/include/stout/hashset.hpp 75ed9db54dc9ab502e978f06c55a621cacb56b91 
  3rdparty/libprocess/3rdparty/stout/tests/hashset_tests.cpp 3c4b732432c0c155451d34ecd5f985318d118fe5 

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


Testing
-------

make check


Thanks,

Alexander Rojas