Removed tr1 stuff.
This commit is contained in:
parent
d4ee76b7bf
commit
beb77d0e2d
@ -2,19 +2,17 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <tr1/unordered_map> // for std::tr1::hash
|
#include <unordered_map> // std::hash
|
||||||
#include "MurmurHash2.h"
|
#include "MurmurHash2.h"
|
||||||
|
|
||||||
#include "benchmark.h"
|
#include "benchmark.h"
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
namespace tr1 {
|
|
||||||
template <> struct hash<cxxmph::StringPiece> {
|
template <> struct hash<cxxmph::StringPiece> {
|
||||||
uint32_t operator()(const cxxmph::StringPiece& k) const {
|
uint32_t operator()(const cxxmph::StringPiece& k) const {
|
||||||
return cxxmph::MurmurHash2(k.data(), k.length(), 1);
|
return cxxmph::MurmurHash2(k.data(), k.length(), 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace tr1
|
|
||||||
} // namespace std
|
} // namespace std
|
||||||
|
|
||||||
namespace cxxmph {
|
namespace cxxmph {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tr1/unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "bm_common.h"
|
#include "bm_common.h"
|
||||||
#include "stringpiece.h"
|
#include "stringpiece.h"
|
||||||
@ -9,7 +9,7 @@
|
|||||||
using namespace cxxmph;
|
using namespace cxxmph;
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::tr1::unordered_map;
|
using std::unordered_map;
|
||||||
|
|
||||||
class BM_MPHIndexCreate : public UrlsBenchmark {
|
class BM_MPHIndexCreate : public UrlsBenchmark {
|
||||||
public:
|
public:
|
||||||
@ -35,7 +35,7 @@ class BM_STLIndexCreate : public UrlsBenchmark {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class BM_MPHIndexSearch : public SearchUrlsBenchmark {
|
class BM_MPHIndexSearch : public SearchUrlsBenchmark {
|
||||||
public:
|
public:
|
||||||
BM_MPHIndexSearch(const std::string& urls_file, int nsearches)
|
BM_MPHIndexSearch(const std::string& urls_file, int nsearches)
|
||||||
@ -76,7 +76,7 @@ class BM_STLIndexSearch : public SearchUrlsBenchmark {
|
|||||||
index.swap(index_);
|
index.swap(index_);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
std::tr1::unordered_map<StringPiece, uint32_t> index_;
|
std::unordered_map<StringPiece, uint32_t> index_;
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
@ -4,38 +4,38 @@
|
|||||||
#include "bm_common.h"
|
#include "bm_common.h"
|
||||||
#include "mph_map.h"
|
#include "mph_map.h"
|
||||||
|
|
||||||
using cxxmph::mph_map;
|
using cxxmph::mph_map;
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::tr1::unordered_map;
|
using std::unordered_map;
|
||||||
|
|
||||||
namespace cxxmph {
|
namespace cxxmph {
|
||||||
|
|
||||||
uint64_t myfind(const unordered_map<uint64_t, uint64_t>& mymap, const uint64_t& k) {
|
uint64_t myfind(const unordered_map<uint64_t, uint64_t>& mymap, const uint64_t& k) {
|
||||||
return mymap.find(k)->second;
|
return mymap.find(k)->second;
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t myfind(const mph_map<uint64_t, uint64_t>& mymap, const uint64_t& k) {
|
|
||||||
return mymap.find(k)->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
const StringPiece& myfind(const unordered_map<StringPiece, StringPiece, Murmur2StringPiece>& mymap, const StringPiece& k) {
|
|
||||||
return mymap.find(k)->second;
|
|
||||||
}
|
|
||||||
StringPiece myfind(const mph_map<StringPiece, StringPiece>& mymap, const StringPiece& k) {
|
|
||||||
auto it = mymap.find(k);
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class MapType>
|
|
||||||
class BM_CreateUrls : public UrlsBenchmark {
|
|
||||||
public:
|
|
||||||
BM_CreateUrls(const string& urls_file) : UrlsBenchmark(urls_file) { }
|
|
||||||
virtual void Run() {
|
|
||||||
MapType mymap;
|
|
||||||
for (auto it = urls_.begin(); it != urls_.end(); ++it) {
|
|
||||||
mymap[*it] = *it;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t myfind(const mph_map<uint64_t, uint64_t>& mymap, const uint64_t& k) {
|
||||||
|
return mymap.find(k)->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
const StringPiece& myfind(const unordered_map<StringPiece, StringPiece, Murmur2StringPiece>& mymap, const StringPiece& k) {
|
||||||
|
return mymap.find(k)->second;
|
||||||
|
}
|
||||||
|
StringPiece myfind(const mph_map<StringPiece, StringPiece>& mymap, const StringPiece& k) {
|
||||||
|
auto it = mymap.find(k);
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class MapType>
|
||||||
|
class BM_CreateUrls : public UrlsBenchmark {
|
||||||
|
public:
|
||||||
|
BM_CreateUrls(const string& urls_file) : UrlsBenchmark(urls_file) { }
|
||||||
|
virtual void Run() {
|
||||||
|
MapType mymap;
|
||||||
|
for (auto it = urls_.begin(); it != urls_.end(); ++it) {
|
||||||
|
mymap[*it] = *it;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class MapType>
|
template <class MapType>
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <tr1/unordered_map> // for std::tr1::hash
|
#include <unordered_map> // for std::hash
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -201,7 +201,7 @@ uint32_t MPHIndex::index(const Key& key) const {
|
|||||||
|
|
||||||
// Simple wrapper around MPHIndex to simplify calling code. Please refer to the
|
// Simple wrapper around MPHIndex to simplify calling code. Please refer to the
|
||||||
// MPHIndex class for documentation.
|
// MPHIndex class for documentation.
|
||||||
template <class Key, class HashFcn = typename seeded_hash<std::tr1::hash<Key> >::hash_function>
|
template <class Key, class HashFcn = typename seeded_hash<std::hash<Key> >::hash_function>
|
||||||
class SimpleMPHIndex : public MPHIndex {
|
class SimpleMPHIndex : public MPHIndex {
|
||||||
public:
|
public:
|
||||||
template <class ForwardIterator>
|
template <class ForwardIterator>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
// use it for educational purposes.
|
// use it for educational purposes.
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <tr1/unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility> // for std::pair
|
#include <utility> // for std::pair
|
||||||
|
|
||||||
@ -15,14 +15,14 @@
|
|||||||
|
|
||||||
namespace cxxmph {
|
namespace cxxmph {
|
||||||
|
|
||||||
using std::tr1::unordered_map;
|
using std::unordered_map;
|
||||||
|
|
||||||
// Save on repetitive typing.
|
// Save on repetitive typing.
|
||||||
#define MPH_MAP_TMPL_SPEC template <class Key, class Data, class HashFcn, class EqualKey, class Alloc>
|
#define MPH_MAP_TMPL_SPEC template <class Key, class Data, class HashFcn, class EqualKey, class Alloc>
|
||||||
#define MPH_MAP_CLASS_SPEC mph_map<Key, Data, HashFcn, EqualKey, Alloc>
|
#define MPH_MAP_CLASS_SPEC mph_map<Key, Data, HashFcn, EqualKey, Alloc>
|
||||||
#define MPH_MAP_METHOD_DECL(r, m) MPH_MAP_TMPL_SPEC typename MPH_MAP_CLASS_SPEC::r MPH_MAP_CLASS_SPEC::m
|
#define MPH_MAP_METHOD_DECL(r, m) MPH_MAP_TMPL_SPEC typename MPH_MAP_CLASS_SPEC::r MPH_MAP_CLASS_SPEC::m
|
||||||
|
|
||||||
template <class Key, class Data, class HashFcn = std::tr1::hash<Key>, class EqualKey = std::equal_to<Key>, class Alloc = std::allocator<Data> >
|
template <class Key, class Data, class HashFcn = std::hash<Key>, class EqualKey = std::equal_to<Key>, class Alloc = std::allocator<Data> >
|
||||||
class mph_map {
|
class mph_map {
|
||||||
public:
|
public:
|
||||||
typedef Key key_type;
|
typedef Key key_type;
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
#include "mph_index.h"
|
|
||||||
|
|
||||||
// String to string map working on mmap'ed memory
|
|
||||||
|
|
||||||
class MPHTable {
|
|
||||||
public:
|
|
||||||
typedef StringPiece key_type;
|
|
||||||
typedef StringPiece data_type;
|
|
||||||
typedef std::pair<StringPiece, StringPiece> value_type;
|
|
||||||
template <class ForwardIterator>
|
|
||||||
bool Reset(ForwardIterator begin, ForwardIterator end);
|
|
||||||
private:
|
|
||||||
char* data_;
|
|
||||||
vector<uint64_t> offsets_;
|
|
||||||
MPHIndex index_;
|
|
||||||
};
|
|
@ -4,7 +4,7 @@
|
|||||||
#include <stdint.h> // for uint32_t and friends
|
#include <stdint.h> // for uint32_t and friends
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <tr1/unordered_map> // for std::tr1::hash
|
#include <unordered_map> // for std::hash
|
||||||
|
|
||||||
#include "MurmurHash2.h"
|
#include "MurmurHash2.h"
|
||||||
#include "stringpiece.h"
|
#include "stringpiece.h"
|
||||||
@ -59,36 +59,36 @@ struct seeded_hash_function<Murmur2StringPiece> {
|
|||||||
|
|
||||||
template <class HashFcn> struct seeded_hash
|
template <class HashFcn> struct seeded_hash
|
||||||
{ typedef seeded_hash_function<HashFcn> hash_function; };
|
{ typedef seeded_hash_function<HashFcn> hash_function; };
|
||||||
// Use Murmur2 instead for all types defined in std::tr1::hash, plus
|
// Use Murmur2 instead for all types defined in std::hash, plus
|
||||||
// std::string which is commonly extended.
|
// std::string which is commonly extended.
|
||||||
template <> struct seeded_hash<std::tr1::hash<char*> >
|
template <> struct seeded_hash<std::hash<char*> >
|
||||||
{ typedef seeded_hash_function<Murmur2StringPiece> hash_function; };
|
{ typedef seeded_hash_function<Murmur2StringPiece> hash_function; };
|
||||||
template <> struct seeded_hash<std::tr1::hash<const char*> >
|
template <> struct seeded_hash<std::hash<const char*> >
|
||||||
{ typedef seeded_hash_function<Murmur2StringPiece> hash_function; };
|
{ typedef seeded_hash_function<Murmur2StringPiece> hash_function; };
|
||||||
template <> struct seeded_hash<std::tr1::hash<std::string> >
|
template <> struct seeded_hash<std::hash<std::string> >
|
||||||
{ typedef seeded_hash_function<Murmur2StringPiece> hash_function; };
|
{ typedef seeded_hash_function<Murmur2StringPiece> hash_function; };
|
||||||
template <> struct seeded_hash<std::tr1::hash<cxxmph::StringPiece> >
|
template <> struct seeded_hash<std::hash<cxxmph::StringPiece> >
|
||||||
{ typedef seeded_hash_function<Murmur2StringPiece> hash_function; };
|
{ typedef seeded_hash_function<Murmur2StringPiece> hash_function; };
|
||||||
|
|
||||||
template <> struct seeded_hash<std::tr1::hash<char> >
|
template <> struct seeded_hash<std::hash<char> >
|
||||||
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
||||||
template <> struct seeded_hash<std::tr1::hash<unsigned char> >
|
template <> struct seeded_hash<std::hash<unsigned char> >
|
||||||
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
||||||
template <> struct seeded_hash<std::tr1::hash<short> >
|
template <> struct seeded_hash<std::hash<short> >
|
||||||
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
||||||
template <> struct seeded_hash<std::tr1::hash<unsigned short> >
|
template <> struct seeded_hash<std::hash<unsigned short> >
|
||||||
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
||||||
template <> struct seeded_hash<std::tr1::hash<int> >
|
template <> struct seeded_hash<std::hash<int> >
|
||||||
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
||||||
template <> struct seeded_hash<std::tr1::hash<unsigned int> >
|
template <> struct seeded_hash<std::hash<unsigned int> >
|
||||||
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
||||||
template <> struct seeded_hash<std::tr1::hash<long> >
|
template <> struct seeded_hash<std::hash<long> >
|
||||||
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
||||||
template <> struct seeded_hash<std::tr1::hash<unsigned long> >
|
template <> struct seeded_hash<std::hash<unsigned long> >
|
||||||
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
||||||
template <> struct seeded_hash<std::tr1::hash<long long> >
|
template <> struct seeded_hash<std::hash<long long> >
|
||||||
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
||||||
template <> struct seeded_hash<std::tr1::hash<unsigned long long> >
|
template <> struct seeded_hash<std::hash<unsigned long long> >
|
||||||
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
{ typedef seeded_hash_function<Murmur2> hash_function; };
|
||||||
|
|
||||||
} // namespace cxxmph
|
} // namespace cxxmph
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#ifndef CXXMPH_STRINGPIECE_H__
|
#ifndef CXXMPH_STRINGPIECE_H__
|
||||||
#define CXXMPH_STRINGPIECE_H__
|
#define CXXMPH_STRINGPIECE_H__
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
Loading…
Reference in New Issue
Block a user