mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ben Mahler" <benjamin.mah...@gmail.com>
Subject Re: Review Request 33792: Add InsensitiveHashMap.
Date Mon, 04 May 2015 21:03:50 GMT


> 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
> 
>


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