A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns3::Hash::Function::Murmur3 Class Reference

Murmur3 hash function implementation. More...

#include <hash-murmur3.h>

+ Inheritance diagram for ns3::Hash::Function::Murmur3:
+ Collaboration diagram for ns3::Hash::Function::Murmur3:

Public Member Functions

 Murmur3 ()
 Constructor, clears internal state. More...
 
virtual void clear (void)
 Restore initial state. More...
 
uint32_t GetHash32 (const char *buffer, const size_t size)
 Compute 32-bit hash of a byte buffer. More...
 
uint64_t GetHash64 (const char *buffer, const size_t size)
 Compute 64-bit hash of a byte buffer. More...
 
- Public Member Functions inherited from ns3::Hash::Implementation
 Implementation ()
 Constructor. More...
 
virtual ~Implementation ()
 Destructor. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Implementation >
 SimpleRefCount ()
 Constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment. More...
 
void Ref (void) const
 Increment the reference count. More...
 
void Unref (void) const
 Decrement the reference count. More...
 

Private Types

enum  seed { SEED = 0x8BADF00D }
 Seed value. More...
 

Private Attributes

uint32_t m_hash32
 Cache last hash value, and total bytes hashed (needed to finalize), for incremental hashing. More...
 
uint32_t m_size32
 Cache last hash value, and total bytes hashed (needed to finalize), for incremental hashing. More...
 
uint64_t m_hash64 [2]
 murmur3 produces 128-bit hash and state; we use just the first 64-bits. More...
 
uint64_t m_size64
 Cache last hash value, and total bytes hashed (needed to finalize), for incremental hashing. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ns3::SimpleRefCount< Implementation >
static void Cleanup (void)
 Noop. More...
 

Detailed Description

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 47 of file hash-murmur3.h.

Member Enumeration Documentation

Seed value.

This has to be a constant for all MPI ranks to generate the same hash from the same string.

Enumerator
SEED 

Definition at line 96 of file hash-murmur3.h.

Constructor & Destructor Documentation

ns3::Hash::Function::Murmur3::Murmur3 ( )

Constructor, clears internal state.

Definition at line 433 of file hash-murmur3.cc.

References clear().

+ Here is the call graph for this function:

Member Function Documentation

void ns3::Hash::Function::Murmur3::clear ( void  )
virtual

Restore initial state.

Implements ns3::Hash::Implementation.

Definition at line 481 of file hash-murmur3.cc.

References m_hash32, m_hash64, m_size32, m_size64, and SEED.

Referenced by Murmur3().

+ Here is the caller graph for this function:

uint32_t ns3::Hash::Function::Murmur3::GetHash32 ( const char *  buffer,
const size_t  size 
)
virtual

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.

Parameters
[in]bufferpointer to the beginning of the buffer
[in]sizelength of the buffer, in bytes
Returns
32-bit hash of the buffer

Implements ns3::Hash::Implementation.

Definition at line 439 of file hash-murmur3.cc.

References m_hash32, m_size32, ns3::Hash::Function::Murmur3Implementation::MurmurHash3_x86_32_fin(), and ns3::Hash::Function::Murmur3Implementation::MurmurHash3_x86_32_incr().

+ Here is the call graph for this function:

uint64_t ns3::Hash::Function::Murmur3::GetHash64 ( const char *  buffer,
const size_t  size 
)
virtual

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.

Parameters
[in]bufferpointer to the beginning of the buffer
[in]sizelength of the buffer, in bytes
Returns
64-bit hash of the buffer

Reimplemented from ns3::Hash::Implementation.

Definition at line 452 of file hash-murmur3.cc.

References m_hash64, m_size64, ns3::Hash::Function::Murmur3Implementation::MurmurHash3_x86_128_fin(), and ns3::Hash::Function::Murmur3Implementation::MurmurHash3_x86_128_incr().

+ Here is the call graph for this function:

Member Data Documentation

uint32_t ns3::Hash::Function::Murmur3::m_hash32
private

Cache last hash value, and total bytes hashed (needed to finalize), for incremental hashing.

Definition at line 105 of file hash-murmur3.h.

Referenced by clear(), and GetHash32().

uint64_t ns3::Hash::Function::Murmur3::m_hash64[2]
private

murmur3 produces 128-bit hash and state; we use just the first 64-bits.

Definition at line 108 of file hash-murmur3.h.

Referenced by clear(), and GetHash64().

uint32_t ns3::Hash::Function::Murmur3::m_size32
private

Cache last hash value, and total bytes hashed (needed to finalize), for incremental hashing.

Definition at line 106 of file hash-murmur3.h.

Referenced by clear(), and GetHash32().

uint64_t ns3::Hash::Function::Murmur3::m_size64
private

Cache last hash value, and total bytes hashed (needed to finalize), for incremental hashing.

Definition at line 109 of file hash-murmur3.h.

Referenced by clear(), and GetHash64().


The documentation for this class was generated from the following files: