Removed tr1 stuff.

This commit is contained in:
Davi de Castro Reis 2011-11-10 16:44:37 -02:00
parent d4ee76b7bf
commit beb77d0e2d
8 changed files with 56 additions and 73 deletions

View File

@ -2,19 +2,17 @@
#include <string>
#include <vector>
#include <tr1/unordered_map> // for std::tr1::hash
#include <unordered_map> // std::hash
#include "MurmurHash2.h"
#include "benchmark.h"
namespace std {
namespace tr1 {
template <> struct hash<cxxmph::StringPiece> {
uint32_t operator()(const cxxmph::StringPiece& k) const {
return cxxmph::MurmurHash2(k.data(), k.length(), 1);
}
};
} // namespace tr1
} // namespace std
namespace cxxmph {

View File

@ -1,6 +1,6 @@
#include <set>
#include <string>
#include <tr1/unordered_map>
#include <unordered_map>
#include "bm_common.h"
#include "stringpiece.h"
@ -9,7 +9,7 @@
using namespace cxxmph;
using std::string;
using std::tr1::unordered_map;
using std::unordered_map;
class BM_MPHIndexCreate : public UrlsBenchmark {
public:
@ -76,7 +76,7 @@ class BM_STLIndexSearch : public SearchUrlsBenchmark {
index.swap(index_);
return true;
}
std::tr1::unordered_map<StringPiece, uint32_t> index_;
std::unordered_map<StringPiece, uint32_t> index_;
};
int main(int argc, char** argv) {

View File

@ -4,38 +4,38 @@
#include "bm_common.h"
#include "mph_map.h"
using cxxmph::mph_map;
using std::string;
using std::tr1::unordered_map;
using cxxmph::mph_map;
using std::string;
using std::unordered_map;
namespace cxxmph {
namespace cxxmph {
uint64_t myfind(const unordered_map<uint64_t, uint64_t>& mymap, const uint64_t& k) {
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 unordered_map<uint64_t, uint64_t>& mymap, const uint64_t& k) {
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;
}
}
};
template <class MapType>

View File

@ -26,7 +26,7 @@
#include <cassert>
#include <cmath>
#include <tr1/unordered_map> // for std::tr1::hash
#include <unordered_map> // for std::hash
#include <vector>
#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
// 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 {
public:
template <class ForwardIterator>

View File

@ -6,7 +6,7 @@
// use it for educational purposes.
#include <algorithm>
#include <tr1/unordered_map>
#include <unordered_map>
#include <vector>
#include <utility> // for std::pair
@ -15,14 +15,14 @@
namespace cxxmph {
using std::tr1::unordered_map;
using std::unordered_map;
// Save on repetitive typing.
#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_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 {
public:
typedef Key key_type;

View File

@ -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_;
};

View File

@ -4,7 +4,7 @@
#include <stdint.h> // for uint32_t and friends
#include <cstdlib>
#include <tr1/unordered_map> // for std::tr1::hash
#include <unordered_map> // for std::hash
#include "MurmurHash2.h"
#include "stringpiece.h"
@ -59,36 +59,36 @@ struct seeded_hash_function<Murmur2StringPiece> {
template <class HashFcn> struct seeded_hash
{ 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.
template <> struct seeded_hash<std::tr1::hash<char*> >
template <> struct seeded_hash<std::hash<char*> >
{ 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; };
template <> struct seeded_hash<std::tr1::hash<std::string> >
template <> struct seeded_hash<std::hash<std::string> >
{ 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; };
template <> struct seeded_hash<std::tr1::hash<char> >
template <> struct seeded_hash<std::hash<char> >
{ 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; };
template <> struct seeded_hash<std::tr1::hash<short> >
template <> struct seeded_hash<std::hash<short> >
{ 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; };
template <> struct seeded_hash<std::tr1::hash<int> >
template <> struct seeded_hash<std::hash<int> >
{ 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; };
template <> struct seeded_hash<std::tr1::hash<long> >
template <> struct seeded_hash<std::hash<long> >
{ 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; };
template <> struct seeded_hash<std::tr1::hash<long long> >
template <> struct seeded_hash<std::hash<long long> >
{ 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; };
} // namespace cxxmph

View File

@ -19,6 +19,7 @@
#ifndef CXXMPH_STRINGPIECE_H__
#define CXXMPH_STRINGPIECE_H__
#include <cstddef>
#include <string.h>
#include <iosfwd>
#include <string>