template <typename _Key, typename _Meta = void>
class HashTableStorage
Defined at line 106 of file ../../src/lib/vmo_store/storage_types.h
A storage base for VmoStore that uses an fbl::HashTable backing.
The hash table nodes are std::unique_ptrs that are fallibly allocated on insertion.
Users should consider `HashTableStorage` over `SlabStorage` if any of the following are true:
- The `Insert` API is expected to be used more than the `Push` API. `SlabStorage` is better
suited than `HashTableStorage` to issue keys, but if the keys are always informed (i.e. the
`RegisterWithKey` API on `VmoStore` is used), then `HashTableStorage` might be a better option.
- There are no guarantees over the key space or the keys are not expected to be tightly packed.
`SlabStorage`'s keys are simply an index in an internal vector. If there are no guarantees over
the size or sparseness of the key set that you expect to use, `HashTableStorage` might be a
better option.
- Upfront memory allocation and memory reuse are not necessary.
- The application can pay the cost of a multiplication and a mod on `Get` and absorb the O(n)
worst-case scenario that comes with hash tables, as opposed to the stronger O(1) guarantees of
`SlabStorage`.
NOTE: This class only supports integer types as keys for simplicity. It can be expanded
with more complex type traits derived from fbl::HashTable, but there's no immediate need for it.
Public Methods
void HashTableStorage<_Key, _Meta> (uint32_t random_seed)
Defined at line 115 of file ../../src/lib/vmo_store/storage_types.h
void HashTableStorage<_Key, _Meta> (HashTableStorage<_Key, _Meta> && other)
Defined at line 118 of file ../../src/lib/vmo_store/storage_types.h
zx_status_t Reserve (size_t capacity)
Defined at line 140 of file ../../src/lib/vmo_store/storage_types.h
zx_status_t Insert (Key key, Item && vmo)
Defined at line 142 of file ../../src/lib/vmo_store/storage_types.h
std::optional<Key> Push (Item && vmo)
Defined at line 155 of file ../../src/lib/vmo_store/storage_types.h
Item * Get (const Key & key)
Defined at line 168 of file ../../src/lib/vmo_store/storage_types.h
std::optional<Item> Extract (Key key)
Defined at line 176 of file ../../src/lib/vmo_store/storage_types.h
size_t count ()
Defined at line 185 of file ../../src/lib/vmo_store/storage_types.h
bool is_full ()
Defined at line 187 of file ../../src/lib/vmo_store/storage_types.h