![]() |
mutable
A Database System for Research and Fast Prototyping
|
#include <WasmAlgo.hpp>
Data Structures | |
struct | ProbingStrategy |
Probing strategy to handle collisions in an open addressing hash table. More... | |
Public Types | |
using | ref_t = uint32_t |
4 bytes for reference counting | |
using | index_t = std::size_t |
using | offset_t = int32_t |
using | size_t = uint32_t |
using | value_t = PrimitiveExpr< typename T::type > |
template<sql_type T> | |
using | reference_t = the_reference< T, false > |
template<sql_type T> | |
using | const_reference_t = the_reference< T, true > |
using | entry_t = the_entry< false > |
using | const_entry_t = the_entry< true > |
using | callback_t = std::function< void(const_entry_t)> |
using | hint_t = std::optional< Ptr< void > > |
Public Member Functions | |
OpenAddressingHashTableBase (const Schema &schema, std::vector< index_t > key_indices) | |
Creates an open addressing hash table with schema schema and keys at key_indices . | |
virtual Ptr< void > | begin () const =0 |
Returns the address of the first entry. | |
virtual Ptr< void > | end () const =0 |
Returns the address of the past-the-end entry. | |
virtual U32x1 | mask () const =0 |
Returns the mask of the hash table, i.e. | |
U32x1 | capacity () const |
Returns the capacity of the hash table. | |
U32x1 | size_in_bytes () const |
Returns the overall size in bytes of the hash table. | |
HashTable::size_t | entry_size_in_bytes () const |
Returns the size in bytes of a single entry in the hash table. | |
template<typename T > | |
void | set_probing_strategy () |
Sets the hash table's probing strategy to. | |
void | set_high_watermark (double percentage) override |
Sets the high watermark, i.e. | |
void | clear () override |
Clears the hash table. | |
template<sql_type T, bool IsConst> requires (not std::same_as<T, NChar>) | |
and (T::num_simd_lanes==1) struct the_reference< T | |
the_reference (Ptr< value_t > value) | |
the_reference (Ptr< value_t > value, Ptr< void > null_bitmap, uint8_t null_bit_offset) | |
void | discard () |
| |
the_reference | clone () const |
| |
void | set_value (value_t value) |
| |
void | set_null_bit (Boolx1 is_null) |
| |
void | set_null () |
| |
void | set_not_null () |
| |
Boolx1 | operator== (T _value) |
| |
operator T () | |
| |
const Schema & | schema () const |
virtual void | setup ()=0 |
Performs the setup of the hash table. | |
virtual void | teardown ()=0 |
Performs the teardown of the hash table. | |
virtual Ptr< void > | compute_bucket (std::vector< SQL_t > key) const =0 |
Computes the bucket for key key . | |
virtual entry_t | emplace (std::vector< SQL_t > key)=0 |
Inserts an entry into the hash table with key key regardless whether it already exists, i.e. | |
virtual std::pair< entry_t, Boolx1 > | try_emplace (std::vector< SQL_t > key)=0 |
If no entry with key key already exists, inserts one into the hash table, i.e. | |
virtual std::pair< entry_t, Boolx1 > | find (std::vector< SQL_t > key, hint_t bucket_hint=hint_t())=0 |
Tries to find an entry with key key in the hash table. | |
std::pair< const_entry_t, Boolx1 > | find (std::vector< SQL_t > key, hint_t bucket_hint=hint_t()) const |
Tries to find an entry with key key in the hash table. | |
virtual void | for_each (callback_t Pipeline) const =0 |
Calls Pipeline for each entry contained in the hash table. | |
virtual void | for_each_in_equal_range (std::vector< SQL_t > key, callback_t Pipeline, bool predicated=false, hint_t bucket_hint=hint_t()) const =0 |
Calls Pipeline for each entry with key key in the hash table, where the key comparison is performed predicated iff predicated is set. | |
virtual entry_t | dummy_entry ()=0 |
Returns a handle to a newly created dummy entry which may be used to write the values for this entry. | |
Data Fields | |
IsConst | |
Protected Member Functions | |
const ProbingStrategy & | probing_strategy () const |
Returns the currently used probing strategy of the hash table. | |
Reference< ref_t > | reference_count (Ptr< void > entry) const |
Returns a Reference to the reference counter for the entry at address entry . | |
virtual void | update_high_watermark () |
Updates internal high watermark variables according to the currently set high watermark percentage. | |
Ptr< void > | hash_to_bucket (std::vector< SQL_t > key) const |
Returns the bucket address for the key key by hashing it. | |
std::pair< size_t, size_t > | set_byte_offsets (std::vector< offset_t > &offsets_in_bytes, const std::vector< const Type * > &types, offset_t initial_offset_in_bytes=0, offset_t initial_max_alignment_in_bytes=1) |
Sets the byte offsets of an entry containing values of types types in offsets_in_bytes with the starting offset at initial_offset_in_bytes and an initial alignment requirement of initial_max_alignment_in_bytes . | |
Static Protected Member Functions | |
static std::vector< SQL_t > | clone (const std::vector< SQL_t > &values) |
| |
Protected Attributes | |
std::unique_ptr< ProbingStrategy > | probing_strategy_ |
probing strategy to handle collisions | |
HashTable::offset_t | refs_offset_in_bytes_ |
offset in bytes for reference counter | |
HashTable::size_t | entry_size_in_bytes_ |
entry size in bytes | |
HashTable::size_t | entry_max_alignment_in_bytes_ |
alignment requirement in bytes of a single entry | |
double | high_watermark_percentage_ = 1.0 |
fraction of occupied entries before growing the hash table is required | |
std::reference_wrapper< const Schema > | schema_ |
schema of hash table | |
std::vector< index_t > | key_indices_ |
keys of hash table | |
std::vector< index_t > | value_indices_ |
values of hash table | |
Private Member Functions | |
the_reference (Ptr< value_t > value, std::optional< Ptr< U8x1 > > is_null_byte, std::optional< U8x1 > is_null_mask) | |
the_reference (Ptr< value_t > value, Ptr< U8x1 > is_null_byte, U8x1 is_null_mask) | |
Private Attributes | |
Ptr< value_t > | value_ |
std::optional< Ptr< U8x1 > > | is_null_byte_ |
std::optional< U8x1 > | is_null_mask_ |
Friends | |
struct | ProbingStrategy |
Definition at line 767 of file WasmAlgo.hpp.
|
inherited |
Definition at line 486 of file WasmAlgo.hpp.
|
inherited |
Definition at line 484 of file WasmAlgo.hpp.
|
inherited |
Definition at line 364 of file WasmAlgo.hpp.
|
inherited |
Definition at line 483 of file WasmAlgo.hpp.
|
inherited |
Definition at line 487 of file WasmAlgo.hpp.
|
inherited |
Definition at line 57 of file WasmAlgo.hpp.
|
inherited |
Definition at line 58 of file WasmAlgo.hpp.
using m::wasm::OpenAddressingHashTableBase::ref_t = uint32_t |
4 bytes for reference counting
Definition at line 771 of file WasmAlgo.hpp.
|
inherited |
Definition at line 362 of file WasmAlgo.hpp.
|
inherited |
Definition at line 59 of file WasmAlgo.hpp.
|
inherited |
Definition at line 75 of file WasmAlgo.hpp.
|
inline |
Creates an open addressing hash table with schema schema
and keys at key_indices
.
Definition at line 800 of file WasmAlgo.hpp.
|
inherited |
|
pure virtual |
Returns the address of the first entry.
Implemented in m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >.
Referenced by m::wasm::LinearProbing::advance_to_next_slot(), clear(), and hash_to_bucket().
|
inline |
Returns the capacity of the hash table.
Definition at line 812 of file WasmAlgo.hpp.
References mask().
Referenced by m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::end(), size_in_bytes(), m::wasm::LinearProbing::skip_slots(), and m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::update_high_watermark().
|
overridevirtual |
Clears the hash table.
Implements m::wasm::HashTable.
Definition at line 1322 of file WasmAlgo.cpp.
References m::wasm::and, begin(), end(), entry_size_in_bytes_, reference_count(), Wasm_insist, and WHILE.
|
inlineinherited |
Returns a deep copy of
this
.
Definition at line 113 of file WasmAlgo.hpp.
References m::wasm::HashTable::is_null_byte_, m::wasm::HashTable::is_null_mask_, and m::wasm::HashTable::value_.
|
inlinestaticprotectedinherited |
Copies the vector of
SQL_t
svalues
.
Definition at line 491 of file WasmAlgo.hpp.
References M_unreachable, and m::wasm::value.
|
pure virtualinherited |
Computes the bucket for key key
.
Often used as hint for find()
and for_each_in_equal_range()
.
Implemented in m::wasm::ChainedHashTable< IsGlobal >, and m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >.
|
inlineinherited |
Discards
this
.
Definition at line 105 of file WasmAlgo.hpp.
References m::wasm::HashTable::is_null_byte_, m::wasm::HashTable::is_null_mask_, and m::wasm::HashTable::value_.
Referenced by m::wasm::HashTable::the_entry< IsConst >::~the_entry().
|
pure virtualinherited |
Returns a handle to a newly created dummy entry which may be used to write the values for this entry.
Note that even if the hash table is globally visible, this entry can only be used locally, i.e. within the function it is created in.
Implemented in m::wasm::ChainedHashTable< IsGlobal >, and m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >.
Inserts an entry into the hash table with key key
regardless whether it already exists, i.e.
duplicates are allowed. Returns a handle to the newly inserted entry which may be used to write the values for this entry. Rehashing of the hash table may be performed. Predication is supported, i.e. an entry is always inserted but can only be found later iff the predication predicate is fulfilled.
Implemented in m::wasm::ChainedHashTable< IsGlobal >, and m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >.
|
pure virtual |
Returns the address of the past-the-end entry.
Implemented in m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >.
Referenced by m::wasm::LinearProbing::advance_to_next_slot(), m::wasm::QuadraticProbing::advance_to_next_slot(), clear(), hash_to_bucket(), m::wasm::LinearProbing::skip_slots(), and m::wasm::QuadraticProbing::skip_slots().
|
inline |
Returns the size in bytes of a single entry in the hash table.
Definition at line 816 of file WasmAlgo.hpp.
References entry_size_in_bytes_.
Referenced by m::wasm::LinearProbing::advance_to_next_slot(), m::wasm::QuadraticProbing::advance_to_next_slot(), m::wasm::LinearProbing::skip_slots(), and m::wasm::QuadraticProbing::skip_slots().
|
inlineinherited |
Tries to find an entry with key key
in the hash table.
Uses bucket_hint
as hint to the bucket address. Returns a pair of a handle to the found entry which may be used to only read the values of this entry (if none is found this handle points to an arbitrary entry and should be ignored) and a boolean flag to indicate whether an element with the specified key was found. Predication is supported, i.e. if the predication predicate is not fulfilled, no entry will be found.
Definition at line 573 of file WasmAlgo.hpp.
References m::wasm::HashTable::find().
|
pure virtualinherited |
Tries to find an entry with key key
in the hash table.
Uses bucket_hint
as hint to the bucket address. Returns a pair of a handle to the found entry which may be used to both read and write the values of this entry (if none is found this handle points to an arbitrary entry and should be ignored) and a boolean flag to indicate whether an element with the specified key was found. Predication is supported, i.e. if the predication predicate is not fulfilled, no entry will be found.
Implemented in m::wasm::ChainedHashTable< IsGlobal >, and m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >.
Referenced by m::wasm::HashTable::find().
|
pure virtualinherited |
Calls Pipeline
for each entry contained in the hash table.
At each call the argument is a handle to the respective entry which may be used to read both the keys and the values of this entry.
Implemented in m::wasm::ChainedHashTable< IsGlobal >, and m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >.
|
pure virtualinherited |
Calls Pipeline
for each entry with key key
in the hash table, where the key comparison is performed predicated iff predicated
is set.
Uses bucket_hint
as hint to the bucket address. At each call the argument is a handle to the respective entry which may be used to read both the keys and the values of this entry. Predication is supported, i.e. if the predication predicate is not fulfilled, the range of entries with an equal key will be empty.
Implemented in m::wasm::ChainedHashTable< IsGlobal >, and m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >.
Returns the bucket address for the key key
by hashing it.
Definition at line 1332 of file WasmAlgo.cpp.
References m::wasm::and, begin(), end(), entry_size_in_bytes_, m::wasm::hash(), m::wasm::HashTable::key_indices_, M_insist, m::wasm::make_signed(), mask(), m::wasm::murmur3_64a_hash(), m::wasm::HashTable::schema_, and Wasm_insist.
|
pure virtual |
Returns the mask of the hash table, i.e.
capacity - 1U, which can be used to mask a hash value into the range of the hash table.
Implemented in m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >.
Referenced by capacity(), hash_to_bucket(), and m::wasm::QuadraticProbing::skip_slots().
|
inlineinherited |
Loads the value of
this
.
Definition at line 175 of file WasmAlgo.hpp.
References m::wasm::HashTable::is_null_byte_, m::wasm::HashTable::is_null_mask_, m::T(), and m::wasm::HashTable::value_.
|
inlineinherited |
Compares
this
with_value
.
Definition at line 163 of file WasmAlgo.hpp.
References m::wasm::and, m::wasm::is_null(), m::wasm::HashTable::is_null_byte_, m::wasm::HashTable::is_null_mask_, m::wasm::value, and m::wasm::HashTable::value_.
|
inlineprotected |
Returns the currently used probing strategy of the hash table.
Definition at line 823 of file WasmAlgo.hpp.
References M_insist, and probing_strategy_.
|
inlineprotected |
Returns a Reference
to the reference counter for the entry at address entry
.
Definition at line 826 of file WasmAlgo.hpp.
References refs_offset_in_bytes_.
Referenced by clear(), and m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::create_predication_dummy().
|
inlineinherited |
Definition at line 531 of file WasmAlgo.hpp.
References m::wasm::HashTable::schema_.
Referenced by m::wasm::HashTable::HashTable().
|
protectedinherited |
Sets the byte offsets of an entry containing values of types types
in offsets_in_bytes
with the starting offset at initial_offset_in_bytes
and an initial alignment requirement of initial_max_alignment_in_bytes
.
To minimize padding, the values are sorted by their alignment requirement. Returns the byte size of an entry and its alignments requirement in bytes.
Definition at line 438 of file WasmAlgo.cpp.
References m::wasm::indices.
Referenced by m::wasm::ChainedHashTable< IsGlobal >::ChainedHashTable(), and m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::OpenAddressingHashTable().
|
inlineoverridevirtual |
Sets the high watermark, i.e.
the fraction of occupied entries before growing the hash table is required, to percentage
.
Implements m::wasm::HashTable.
Definition at line 831 of file WasmAlgo.hpp.
References high_watermark_percentage_, and update_high_watermark().
|
inlineinherited |
Sets
this
to NOT NULL. Does not modify the value ofthis
.
Definition at line 155 of file WasmAlgo.hpp.
References m::wasm::HashTable::is_null_byte_, m::wasm::HashTable::is_null_mask_, M_insist, and m::wasm::HashTable::value_.
|
inlineinherited |
Sets
this
to NULL. Does not modify the value ofthis
.
Definition at line 148 of file WasmAlgo.hpp.
References m::wasm::HashTable::is_null_byte_, m::wasm::HashTable::is_null_mask_, M_insist, and m::wasm::HashTable::value_.
|
inlineinherited |
Assigns the NULL bit of
this
tois_null
. Does not update/modify the value ofthis
.
Definition at line 141 of file WasmAlgo.hpp.
References m::wasm::is_null(), m::wasm::HashTable::is_null_byte_, m::wasm::HashTable::is_null_mask_, M_insist, m::setbit(), and m::wasm::HashTable::value_.
|
inline |
Sets the hash table's probing strategy to.
T. |
Definition at line 820 of file WasmAlgo.hpp.
References probing_strategy_.
|
inlineinherited |
Assigns the value of
this
tovalue
w/o updating the NULL bit.
Definition at line 132 of file WasmAlgo.hpp.
References m::wasm::HashTable::is_null_byte_, m::wasm::HashTable::is_null_mask_, m::wasm::value, and m::wasm::HashTable::value_.
|
pure virtualinherited |
Performs the setup of the hash table.
Must be called before any call to a setup method, i.e. setting the high watermark, or an access method, i.e. clearing, insertion, lookup, or dummy entry creation.
Implemented in m::wasm::ChainedHashTable< IsGlobal >, and m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >.
|
inline |
Returns the overall size in bytes of the hash table.
Definition at line 814 of file WasmAlgo.hpp.
References capacity(), and entry_size_in_bytes_.
Referenced by m::wasm::QuadraticProbing::advance_to_next_slot(), m::wasm::LinearProbing::skip_slots(), and m::wasm::QuadraticProbing::skip_slots().
|
pure virtualinherited |
Performs the teardown of the hash table.
Must be called after all calls to a setup method, i.e. setting the high watermark, or an access method, i.e. clearing, insertion, lookup, or dummy entry creation.
Implemented in m::wasm::ChainedHashTable< IsGlobal >, and m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >.
|
inlineexplicitinherited |
Definition at line 97 of file WasmAlgo.hpp.
|
inlineexplicitprivateinherited |
Definition at line 90 of file WasmAlgo.hpp.
|
inlineexplicitinherited |
Definition at line 98 of file WasmAlgo.hpp.
|
inlineexplicitprivateinherited |
Definition at line 82 of file WasmAlgo.hpp.
References m::wasm::HashTable::is_null_byte_, m::wasm::HashTable::is_null_mask_, and M_insist.
|
pure virtualinherited |
If no entry with key key
already exists, inserts one into the hash table, i.e.
no duplicates are inserted. Returns a pair of a handle to the entry with the given key which may be used to write the values for this entry and a boolean flag to indicate whether an insertion was performed. Rehashing of the hash table may be performed. Predication is supported, i.e. an entry is always inserted but can only be found later iff the predication predicate is fulfilled.
Implemented in m::wasm::ChainedHashTable< IsGlobal >, and m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >.
|
inlineprotectedvirtual |
Updates internal high watermark variables according to the currently set high watermark percentage.
Reimplemented in m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >.
Definition at line 842 of file WasmAlgo.hpp.
Referenced by set_high_watermark().
|
friend |
Definition at line 769 of file WasmAlgo.hpp.
|
protected |
alignment requirement in bytes of a single entry
Definition at line 795 of file WasmAlgo.hpp.
Referenced by m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::create_predication_dummy(), and m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::OpenAddressingHashTable().
|
protected |
entry size in bytes
Definition at line 794 of file WasmAlgo.hpp.
Referenced by clear(), m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::create_predication_dummy(), m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::end(), entry_size_in_bytes(), hash_to_bucket(), m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::OpenAddressingHashTable(), and size_in_bytes().
|
protected |
fraction of occupied entries before growing the hash table is required
Definition at line 796 of file WasmAlgo.hpp.
Referenced by set_high_watermark(), and m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::update_high_watermark().
|
privateinherited |
Definition at line 79 of file WasmAlgo.hpp.
Referenced by m::wasm::HashTable::clone(), m::wasm::HashTable::the_reference< NChar, IsConst >::clone(), m::wasm::HashTable::discard(), m::wasm::HashTable::the_reference< NChar, IsConst >::discard(), m::wasm::HashTable::the_reference< NChar, IsConst >::operator NChar(), m::wasm::HashTable::operator T(), m::wasm::HashTable::the_reference< NChar, IsConst >::operator=(), m::wasm::HashTable::operator=(), m::wasm::HashTable::the_reference< NChar, IsConst >::operator==(), m::wasm::HashTable::operator==(), m::wasm::HashTable::set_not_null(), m::wasm::HashTable::the_reference< NChar, IsConst >::set_not_null(), m::wasm::HashTable::set_null(), m::wasm::HashTable::the_reference< NChar, IsConst >::set_null(), m::wasm::HashTable::set_null_bit(), m::wasm::HashTable::the_reference< NChar, IsConst >::set_null_bit(), m::wasm::HashTable::the_reference< NChar, IsConst >::set_value(), m::wasm::HashTable::set_value(), m::wasm::HashTable::the_reference< NChar, IsConst >::the_reference(), and m::wasm::HashTable::the_reference().
|
privateinherited |
Definition at line 80 of file WasmAlgo.hpp.
Referenced by m::wasm::HashTable::clone(), m::wasm::HashTable::the_reference< NChar, IsConst >::clone(), m::wasm::HashTable::discard(), m::wasm::HashTable::the_reference< NChar, IsConst >::discard(), m::wasm::HashTable::the_reference< NChar, IsConst >::operator NChar(), m::wasm::HashTable::operator T(), m::wasm::HashTable::the_reference< NChar, IsConst >::operator=(), m::wasm::HashTable::operator=(), m::wasm::HashTable::the_reference< NChar, IsConst >::operator==(), m::wasm::HashTable::operator==(), m::wasm::HashTable::set_not_null(), m::wasm::HashTable::the_reference< NChar, IsConst >::set_not_null(), m::wasm::HashTable::set_null(), m::wasm::HashTable::the_reference< NChar, IsConst >::set_null(), m::wasm::HashTable::set_null_bit(), m::wasm::HashTable::the_reference< NChar, IsConst >::set_null_bit(), m::wasm::HashTable::the_reference< NChar, IsConst >::set_value(), m::wasm::HashTable::set_value(), m::wasm::HashTable::the_reference< NChar, IsConst >::the_reference(), and m::wasm::HashTable::the_reference().
|
inherited |
Definition at line 70 of file WasmAlgo.hpp.
|
protectedinherited |
keys of hash table
Definition at line 505 of file WasmAlgo.hpp.
Referenced by hash_to_bucket(), m::wasm::HashTable::HashTable(), and m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::OpenAddressingHashTable().
|
protected |
probing strategy to handle collisions
Definition at line 792 of file WasmAlgo.hpp.
Referenced by probing_strategy(), and set_probing_strategy().
|
protected |
offset in bytes for reference counter
Definition at line 793 of file WasmAlgo.hpp.
Referenced by m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::OpenAddressingHashTable(), and reference_count().
|
protectedinherited |
schema of hash table
Definition at line 504 of file WasmAlgo.hpp.
Referenced by m::wasm::ChainedHashTable< IsGlobal >::ChainedHashTable(), hash_to_bucket(), m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::OpenAddressingHashTable(), and m::wasm::HashTable::schema().
Definition at line 78 of file WasmAlgo.hpp.
Referenced by m::wasm::HashTable::clone(), m::wasm::HashTable::discard(), m::wasm::HashTable::operator T(), m::wasm::HashTable::operator=(), m::wasm::HashTable::operator==(), m::wasm::HashTable::set_not_null(), m::wasm::HashTable::set_null(), m::wasm::HashTable::set_null_bit(), and m::wasm::HashTable::set_value().
|
protectedinherited |
values of hash table
Definition at line 506 of file WasmAlgo.hpp.
Referenced by m::wasm::HashTable::HashTable(), and m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::OpenAddressingHashTable().