ATLAS Offline Software
|
Table of hash entries. More...
Public Types | |
using | TableIterator = CHMTableIterator< ENTRIES_PER_CACHELINE > |
Public Member Functions | |
Table (size_t capacity, const Hasher_t &hasher=Hasher_t(), const Matcher_t &matcher=Matcher_t()) | |
Constructor. More... | |
void | operator delete (void *p) |
Deallocator for table objects. More... | |
size_t | probeRead (val_t key, size_t hash) const |
Find a table entry for reading. More... | |
size_t | probeWrite (val_t key, size_t hash, bool &insert) |
Find a table entry for writing. More... | |
size_t | capacity () const |
The number of entries in the table. More... | |
const entry_t & | entry (size_t offset) const |
Return the entry for an offset. More... | |
entry_t & | entry (size_t offset) |
Return the entry for an offset (non-const). More... | |
Static Public Member Functions | |
static void * | operator new (size_t, size_t capacity) |
Allocator for table objects. More... | |
Private Attributes | |
const size_t | m_capacity |
Number of entries in the table. Must be a power of 2. More... | |
const size_t | m_maxProbe |
Maximum number of probes allowed before resizing the table. More... | |
const size_t | m_mask |
Mask for table indices (capacity-1). More... | |
const size_t | m_maskBits |
Number of bits in the mask. More... | |
const Hasher_t & | m_hasher |
The hash object. More... | |
const Matcher_t & | m_matcher |
The key match object. More... | |
std::atomic< size_t > | m_longestProbe |
Longest probe needed so far. More... | |
entry_t | m_entries [1] |
The actual table entries. More... | |
Table of hash entries.
This is the actual table of hash entries. It consists of a fixed-size header, followed by the actual array of entries. We override new in order to be able to properly allocate the space for the array. The start of the array of entries need to be aligned on a cache line. We make a new instance of this if the table needs to be grown.
Definition at line 261 of file ConcurrentHashmapImpl.h.
using CxxUtils::detail::ConcurrentHashmapImpl< UPDATER_, HASHER_, MATCHER_, NULLVAL_, TOMBSTONE_ >::Table::TableIterator = CHMTableIterator<ENTRIES_PER_CACHELINE> |
Definition at line 264 of file ConcurrentHashmapImpl.h.
CxxUtils::detail::ConcurrentHashmapImpl< UPDATER_, HASHER_, MATCHER_, NULLVAL_, TOMBSTONE_ >::Table::Table | ( | size_t | capacity, |
const Hasher_t & | hasher = Hasher_t() , |
||
const Matcher_t & | matcher = Matcher_t() |
||
) |
Constructor.
capacity | Number of entries in the table. Must be a power of 2. |
hasher | Hash object to use. |
matcher | Key match object to use. |
size_t CxxUtils::detail::ConcurrentHashmapImpl< UPDATER_, HASHER_, MATCHER_, NULLVAL_, TOMBSTONE_ >::Table::capacity | ( | ) | const |
The number of entries in the table.
entry_t& CxxUtils::detail::ConcurrentHashmapImpl< UPDATER_, HASHER_, MATCHER_, NULLVAL_, TOMBSTONE_ >::Table::entry | ( | size_t | offset | ) |
Return the entry for an offset (non-const).
offset | The index of the desired entry. |
const entry_t& CxxUtils::detail::ConcurrentHashmapImpl< UPDATER_, HASHER_, MATCHER_, NULLVAL_, TOMBSTONE_ >::Table::entry | ( | size_t | offset | ) | const |
Return the entry for an offset.
offset | The index of the desired entry. |
void CxxUtils::detail::ConcurrentHashmapImpl< UPDATER_, HASHER_, MATCHER_, NULLVAL_, TOMBSTONE_ >::Table::operator delete | ( | void * | p | ) |
Deallocator for table objects.
|
static |
Allocator for table objects.
capacity | Size of the table (must be a power of 2). |
Allocate with enough space for the table of entries. Also align on a cache line.
size_t CxxUtils::detail::ConcurrentHashmapImpl< UPDATER_, HASHER_, MATCHER_, NULLVAL_, TOMBSTONE_ >::Table::probeRead | ( | val_t | key, |
size_t | hash | ||
) | const |
Find a table entry for reading.
key | The key for which to search. |
hash | The hash of the key. |
Returns the matching entry, or nullptr.
size_t CxxUtils::detail::ConcurrentHashmapImpl< UPDATER_, HASHER_, MATCHER_, NULLVAL_, TOMBSTONE_ >::Table::probeWrite | ( | val_t | key, |
size_t | hash, | ||
bool & | insert | ||
) |
Find a table entry for writing.
key | The key for which to search. |
hash | The hash of the key. |
entry[out] | The entry found. |
If we find the entry, return true with entry
pointing at it. If we don't find it, and there's still room in the table, return false with entry
pointing at the next empty entry. Otherwise, return false with entry
set to nullptr.
|
private |
Number of entries in the table. Must be a power of 2.
Definition at line 340 of file ConcurrentHashmapImpl.h.
|
private |
The actual table entries.
Definition at line 354 of file ConcurrentHashmapImpl.h.
|
private |
The hash object.
Definition at line 348 of file ConcurrentHashmapImpl.h.
|
private |
Longest probe needed so far.
Definition at line 352 of file ConcurrentHashmapImpl.h.
|
private |
Mask for table indices (capacity-1).
Definition at line 344 of file ConcurrentHashmapImpl.h.
|
private |
Number of bits in the mask.
Definition at line 346 of file ConcurrentHashmapImpl.h.
|
private |
The key match object.
Definition at line 350 of file ConcurrentHashmapImpl.h.
|
private |
Maximum number of probes allowed before resizing the table.
Definition at line 342 of file ConcurrentHashmapImpl.h.