Murmur3 hash function implementation. More...
#include "hash-murmur3.h"
Public Member Functions | |
Murmur3 () | |
Constructor, clears internal state. | |
void | clear () override |
Restore initial state. | |
uint32_t | GetHash32 (const char *buffer, const std::size_t size) override |
Compute 32-bit hash of a byte buffer. | |
uint64_t | GetHash64 (const char *buffer, const std::size_t size) override |
Compute 64-bit hash of a byte buffer. | |
Public Member Functions inherited from ns3::Hash::Implementation | |
Implementation () | |
Constructor. | |
virtual | ~Implementation () |
Destructor. | |
Public Member Functions inherited from ns3::SimpleRefCount< Implementation > | |
SimpleRefCount () | |
Default constructor. | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. | |
uint32_t | GetReferenceCount () const |
Get the reference count of the object. | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment operator. | |
void | Ref () const |
Increment the reference count. | |
void | Unref () const |
Decrement the reference count. | |
Private Attributes | |
uint32_t | m_hash32 |
Cache last hash value, and total bytes hashed (needed to finalize), for incremental hashing. | |
std::size_t | m_size32 |
Cache last hash value, and total bytes hashed (needed to finalize), for incremental hashing. | |
uint64_t | m_hash64 [2] |
murmur3 produces 128-bit hash and state; we use just the first 64-bits. | |
std::size_t | m_size64 |
murmur3 produces 128-bit hash and state; we use just the first 64-bits. | |
Static Private Attributes | |
static constexpr auto | SEED {0x8BADF00D} |
Seed value. | |
Murmur3 hash function implementation.
Adapted from http://code.google.com/p/smhasher/
MurmurHash3 was written by Austin Appleby, and is placed in the public domain. The author hereby disclaims copyright to this source code.
Note - The x86 and x64 versions do not produce the same results, as the algorithms are optimized for their respective platforms. You can still compile and run any of them on any platform, but your performance with the non-native version will be less than optimal.
Definition at line 44 of file hash-murmur3.h.
ns3::Hash::Function::Murmur3::Murmur3 | ( | ) |
Constructor, clears internal state.
Definition at line 512 of file hash-murmur3.cc.
References clear().
|
overridevirtual |
Restore initial state.
Implements ns3::Hash::Implementation.
Definition at line 559 of file hash-murmur3.cc.
References m_hash32, m_hash64, m_size32, m_size64, and SEED.
Referenced by Murmur3().
|
overridevirtual |
Compute 32-bit hash of a byte buffer.
Call clear () between calls to GetHash32() to reset the internal state and hash each buffer separately.
If you don't call clear() between calls to GetHash32, you can hash successive buffers. The final return value will be the cumulative hash across all calls.
[in] | buffer | pointer to the beginning of the buffer |
[in] | size | length of the buffer, in bytes |
Implements ns3::Hash::Implementation.
Definition at line 518 of file hash-murmur3.cc.
|
overridevirtual |
Compute 64-bit hash of a byte buffer.
Call clear () between calls to GetHash64() to reset the internal state and hash each buffer separately.
If you don't call clear() between calls to GetHash64, you can hash successive buffers. The final return value will be the cumulative hash across all calls.
[in] | buffer | pointer to the beginning of the buffer |
[in] | size | length of the buffer, in bytes |
Reimplemented from ns3::Hash::Implementation.
Definition at line 531 of file hash-murmur3.cc.
|
private |
Cache last hash value, and total bytes hashed (needed to finalize), for incremental hashing.
Definition at line 100 of file hash-murmur3.h.
Referenced by clear(), and GetHash32().
|
private |
murmur3 produces 128-bit hash and state; we use just the first 64-bits.
Definition at line 106 of file hash-murmur3.h.
Referenced by clear(), and GetHash64().
|
private |
Cache last hash value, and total bytes hashed (needed to finalize), for incremental hashing.
Definition at line 101 of file hash-murmur3.h.
Referenced by clear(), and GetHash32().
|
private |
murmur3 produces 128-bit hash and state; we use just the first 64-bits.
Definition at line 107 of file hash-murmur3.h.
Referenced by clear(), and GetHash64().
|
staticconstexprprivate |
Seed value.
This has to be a constant for all MPI ranks to generate the same hash from the same string.
Definition at line 93 of file hash-murmur3.h.
Referenced by clear().