0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MurmurHash.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
30 #ifndef HYPERTABLE_MURMURHASH_H
31 #define HYPERTABLE_MURMURHASH_H
32 
33 #include "Common/String.h"
34 
35 namespace Hypertable {
36 
49 extern uint32_t murmurhash2(const void *data, size_t len, uint32_t hash);
50 
58 struct MurmurHash2 {
60  uint32_t operator()(const String& s) const {
61  return murmurhash2(s.c_str(), s.length(), 0);
62  }
63 
65  uint32_t operator()(const void *start, size_t len, uint32_t seed = 0) const {
66  return murmurhash2(start, len, seed);
67  }
68 
70  uint32_t operator()(const char *s) const {
71  return murmurhash2(s, strlen(s), 0);
72  }
73 };
74 
77 } // namespace Hypertable
78 
79 #endif // HYPERTABLE_MURMURHASH_H
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
uint32_t operator()(const char *s) const
Returns hash of a null terminated memory buffer.
Definition: MurmurHash.h:70
uint32_t operator()(const String &s) const
Returns hash of a String.
Definition: MurmurHash.h:60
uint32_t murmurhash2(const void *key, size_t len, uint32_t seed)
The murmurhash2 implementation.
Definition: MurmurHash.cc:29
uint32_t operator()(const void *start, size_t len, uint32_t seed=0) const
Returns hash of a memory buffer.
Definition: MurmurHash.h:65
Hypertable definitions
Helper structure using overloaded operator() to calculate hashes of various input types...
Definition: MurmurHash.h:58
A String class based on std::string.