You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@mesos.apache.org by haosdent huang <ha...@gmail.com> on 2015/05/03 11:37:29 UTC

Review Request 33792: Add InsensitiveHashMap.

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

Review request for mesos and Ben Mahler.


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


Repository: mesos


Description
-------

Add InsensitiveHashMap.


Diffs
-----

  3rdparty/libprocess/3rdparty/stout/include/Makefile.am 79239d738d0607364f8c3d7addfd54a642bdffc0 
  3rdparty/libprocess/3rdparty/stout/include/stout/insensitivehashmap.hpp PRE-CREATION 
  3rdparty/libprocess/3rdparty/stout/tests/insensitivehashmap_tests.cpp PRE-CREATION 

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


Testing
-------

make check


Thanks,

haosdent huang


Re: Review Request 33792: Add InsensitiveHashMap.

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


Patch looks great!

Reviews applied: [33792]

All tests passed.

- Mesos ReviewBot


On May 3, 2015, 9:37 a.m., haosdent huang wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/33792/
> -----------------------------------------------------------
> 
> (Updated May 3, 2015, 9:37 a.m.)
> 
> 
> Review request for mesos and Ben Mahler.
> 
> 
> Bugs: MESOS-328
>     https://issues.apache.org/jira/browse/MESOS-328
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Add InsensitiveHashMap.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/stout/include/Makefile.am 79239d738d0607364f8c3d7addfd54a642bdffc0 
>   3rdparty/libprocess/3rdparty/stout/include/stout/insensitivehashmap.hpp PRE-CREATION 
>   3rdparty/libprocess/3rdparty/stout/tests/insensitivehashmap_tests.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/33792/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> haosdent huang
> 
>


Re: Review Request 33792: Extend hashmap to support custom equality and hash

Posted by haosdent huang <ha...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/33792/
-----------------------------------------------------------

(Updated May 9, 2015, 2:56 p.m.)


Review request for mesos and Ben Mahler.


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

Extend hashmap to support custom equality and hash


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


Repository: mesos


Description
-------

Add InsensitiveHashMap.


Diffs (updated)
-----

  3rdparty/libprocess/3rdparty/stout/include/stout/hashmap.hpp 24dc369ec271ec2f35449e6ccf49c5b829ca6ce8 
  3rdparty/libprocess/3rdparty/stout/tests/hashmap_tests.cpp e8a932e5474bf2ba1a93a945ff9bc61fb5146c02 

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


Testing
-------

make check


Thanks,

haosdent huang


Re: Review Request 33792: Add InsensitiveHashMap.

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

> On May 4, 2015, 6:46 p.m., Alexander Rojas wrote:
> > I am not really sure this is the way to go in order to create a case insensite hashmap. The class `hashmap` simply adds functionality to the `boost::unordered_map`. If one checks the API for the latter, the way needed to create an insensitive hashmap is to override the template parameters `Hash` and `Pred`. So I think it would be better simply to expose them in hashmap changin `stout/hashmpa.hpp` to:
> > 
> > ```cpp
> > template <typename Key, typename Value, typename Hash = boost::hash<Key>, typename Pred = std::equal_to<Key>>
> > class hashmap : public boost::unoredered_map<Key, Value, Hash, Pred>
> > {
> >   …
> > };
> > ```
> > 
> > The you only need to define functors that provide insensitive operatiosn for `Hash` and `Pred` and finally a typedef.

Another approach here is to define a type for the key which captures what we want ('CaseInsensitiveString'), this lets us capture it in the type signature cleanly: hashmap<CaseInsensitiveString, string>.

But, in line with what Alex wrote, and from my [comment](https://issues.apache.org/jira/browse/MESOS-328?focusedCommentId=14526217&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14526217) in MESOS-328, I'd suggest one of the following:

(1) Use unordered_map with custom equality and hash in http::Request / http::Response (we have c++11 now so can assume the presence of std::unordered_map).
(2) Extend hashmap to support custom equality and hash, and use this in http::Request / http::Response.


- Ben


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


On May 3, 2015, 9:37 a.m., haosdent huang wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/33792/
> -----------------------------------------------------------
> 
> (Updated May 3, 2015, 9:37 a.m.)
> 
> 
> Review request for mesos and Ben Mahler.
> 
> 
> Bugs: MESOS-328
>     https://issues.apache.org/jira/browse/MESOS-328
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Add InsensitiveHashMap.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/stout/include/Makefile.am 79239d738d0607364f8c3d7addfd54a642bdffc0 
>   3rdparty/libprocess/3rdparty/stout/include/stout/insensitivehashmap.hpp PRE-CREATION 
>   3rdparty/libprocess/3rdparty/stout/tests/insensitivehashmap_tests.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/33792/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> haosdent huang
> 
>


Re: Review Request 33792: Extend hashmap to support custom equality and hash

Posted by haosdent huang <ha...@gmail.com>.

> On May 4, 2015, 6:46 p.m., Alexander Rojas wrote:
> > I am not really sure this is the way to go in order to create a case insensite hashmap. The class `hashmap` simply adds functionality to the `boost::unordered_map`. If one checks the API for the latter, the way needed to create an insensitive hashmap is to override the template parameters `Hash` and `Pred`. So I think it would be better simply to expose them in hashmap changin `stout/hashmpa.hpp` to:
> > 
> > ```cpp
> > template <typename Key, typename Value, typename Hash = boost::hash<Key>, typename Pred = std::equal_to<Key>>
> > class hashmap : public boost::unoredered_map<Key, Value, Hash, Pred>
> > {
> >   …
> > };
> > ```
> > 
> > The you only need to define functors that provide insensitive operatiosn for `Hash` and `Pred` and finally a typedef.
> 
> Ben Mahler wrote:
>     Another approach here is to define a type for the key which captures what we want ('CaseInsensitiveString'), this lets us capture it in the type signature cleanly: hashmap<CaseInsensitiveString, string>.
>     
>     But, in line with what Alex wrote, and from my [comment](https://issues.apache.org/jira/browse/MESOS-328?focusedCommentId=14526217&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14526217) in MESOS-328, I'd suggest one of the following:
>     
>     (1) Use unordered_map with custom equality and hash in http::Request / http::Response (we have c++11 now so can assume the presence of std::unordered_map).
>     (2) Extend hashmap to support custom equality and hash, and use this in http::Request / http::Response.

@arojas @bmahler I update the patch and I choose exterd hashmap to support custom equality and hash. But I am not sure where should I add the InsensitiveHash and InsensitiveEqual now. I put them in http.hpp now, you could check it out from another [review](https://reviews.apache.org/r/33793/diff/#). By the way, I not sure whether I should add a typedef or not. And If I want add a typedef, should I add it to http.hpp or hashmap.hpp?


- haosdent


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


On May 9, 2015, 3:04 p.m., haosdent huang wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/33792/
> -----------------------------------------------------------
> 
> (Updated May 9, 2015, 3:04 p.m.)
> 
> 
> Review request for mesos, Alexander Rojas and Ben Mahler.
> 
> 
> Bugs: MESOS-328
>     https://issues.apache.org/jira/browse/MESOS-328
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Add InsensitiveHashMap.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/stout/include/stout/hashmap.hpp 24dc369ec271ec2f35449e6ccf49c5b829ca6ce8 
>   3rdparty/libprocess/3rdparty/stout/tests/hashmap_tests.cpp e8a932e5474bf2ba1a93a945ff9bc61fb5146c02 
> 
> Diff: https://reviews.apache.org/r/33792/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> haosdent huang
> 
>


Re: Review Request 33792: Add InsensitiveHashMap.

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


I am not really sure this is the way to go in order to create a case insensite hashmap. The class `hashmap` simply adds functionality to the `boost::unordered_map`. If one checks the API for the latter, the way needed to create an insensitive hashmap is to override the template parameters `Hash` and `Pred`. So I think it would be better simply to expose them in hashmap changin `stout/hashmpa.hpp` to:

```cpp
template <typename Key, typename Value, typename Hash = boost::hash<Key>, typename Pred = std::equal_to<Key>>
class hashmap : public boost::unoredered_map<Key, Value, Hash, Pred>
{
  …
};
```

The you only need to define functors that provide insensitive operatiosn for `Hash` and `Pred` and finally a typedef.

- Alexander Rojas


On May 3, 2015, 11:37 a.m., haosdent huang wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/33792/
> -----------------------------------------------------------
> 
> (Updated May 3, 2015, 11:37 a.m.)
> 
> 
> Review request for mesos and Ben Mahler.
> 
> 
> Bugs: MESOS-328
>     https://issues.apache.org/jira/browse/MESOS-328
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Add InsensitiveHashMap.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/stout/include/Makefile.am 79239d738d0607364f8c3d7addfd54a642bdffc0 
>   3rdparty/libprocess/3rdparty/stout/include/stout/insensitivehashmap.hpp PRE-CREATION 
>   3rdparty/libprocess/3rdparty/stout/tests/insensitivehashmap_tests.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/33792/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> haosdent huang
> 
>