libfoedus-core
FOEDUS Core Library
|
A simple hash function logic used in snasphot cache. More...
A simple hash function logic used in snasphot cache.
The hash key is SnapshotPagePointer, whose least significant bits are local page IDs, which are sequnetial. To avoid placing adjacent page IDs in adjacent hash buckets, we use byte-swap and a few bit shifts, then divide by logical table size which is adjusted to an almost-prime number.
Definition at line 90 of file cache_hashtable.hpp.
#include <cache_hashtable.hpp>
Public Member Functions | |
HashFunc (BucketId physical_buckets) | |
BucketId | get_bucket_number (storage::SnapshotPagePointer page_id) const __attribute__((always_inline)) |
Returns a bucket number the given snapshot page ID should belong to. More... | |
Static Public Member Functions | |
static uint32_t | get_hash (storage::SnapshotPagePointer page_id) __attribute__((always_inline)) |
Returns a hash value for the given snapshot page ID. More... | |
static PageIdTag | get_tag (storage::SnapshotPagePointer page_id) __attribute__((always_inline)) |
Returns another hash value used to differentiate IDs with similar hash values. More... | |
Public Attributes | |
const BucketId | logical_buckets_ |
Number of logical (actually used) buckets in this table. More... | |
const BucketId | physical_buckets_ |
Number of buckets that are physically allocated, at least kHopNeighbors more than logical. More... | |
const assorted::ConstDiv | bucket_div_ |
to efficiently divide a number by bucket_div_. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &o, const HashFunc &v) |
|
explicit |
Definition at line 60 of file cache_hashtable.cpp.
|
inline |
Returns a bucket number the given snapshot page ID should belong to.
Definition at line 110 of file cache_hashtable.hpp.
References ASSERT_ND, foedus::assorted::ConstDiv::div32(), get_hash(), and foedus::assorted::ConstDiv::rem32().
Referenced by foedus::cache::CacheHashtable::get_bucket_number().
|
inlinestatic |
Returns a hash value for the given snapshot page ID.
This needs no member variables.
Definition at line 384 of file cache_hashtable.hpp.
References foedus::storage::extract_local_page_id_from_snapshot_pointer(), foedus::storage::extract_numa_node_from_snapshot_pointer(), and foedus::storage::extract_snapshot_id_from_snapshot_pointer().
Referenced by get_bucket_number().
|
inlinestatic |
Returns another hash value used to differentiate IDs with similar hash values.
Definition at line 406 of file cache_hashtable.hpp.
Referenced by foedus::cache::CacheHashtable::find(), foedus::cache::CacheHashtable::find_batch(), and foedus::cache::CacheHashtable::install().
|
friend |
Definition at line 332 of file cache_hashtable.cpp.
const assorted::ConstDiv foedus::cache::HashFunc::bucket_div_ |
to efficiently divide a number by bucket_div_.
Definition at line 96 of file cache_hashtable.hpp.
const BucketId foedus::cache::HashFunc::logical_buckets_ |
Number of logical (actually used) buckets in this table.
Definition at line 92 of file cache_hashtable.hpp.
Referenced by foedus::cache::CacheHashtable::get_logical_buckets(), and foedus::cache::operator<<().
const BucketId foedus::cache::HashFunc::physical_buckets_ |
Number of buckets that are physically allocated, at least kHopNeighbors more than logical.
Definition at line 94 of file cache_hashtable.hpp.
Referenced by foedus::cache::CacheHashtable::get_physical_buckets(), and foedus::cache::operator<<().