use crate::containers::FastVec;
use crate::hash_map::cache_locality::{CacheOptimizedBucket, Prefetcher};
use std::mem::MaybeUninit;
#[allow(dead_code)] pub(super) enum HashMapStorage<K, V>
where
K: Clone,
V: Clone,
{
Standard {
buckets: FastVec<StandardBucket<K, V>>,
entries: FastVec<HashEntry<K, V>>,
mask: usize,
},
SmallInline {
inline_data: InlineStorage<K, V>,
fallback: Option<Box<HashMapStorage<K, V>>>,
len: usize,
},
CacheOptimized {
buckets: FastVec<CacheOptimizedBucket<K, V>>,
hot_data: FastVec<K>,
cold_data: FastVec<V>,
prefetcher: Prefetcher,
},
StringOptimized {
arena: StringArena,
buckets: FastVec<StringBucket>,
entries: FastVec<StringEntry<V>>,
prefix_cache: FastVec<PrefixCacheEntry>,
},
}
#[repr(align(64))]
pub(super) struct StandardBucket<K, V> {
pub(super) _hash: u64,
pub(super) _key: K,
pub(super) _value: V,
pub(super) _probe_distance: u16,
pub(super) _is_occupied: bool,
}
pub(super) struct InlineStorage<K, V> {
pub(super) _data: [MaybeUninit<(K, V)>; 16], pub(super) occupied: u16, }
impl<K, V> InlineStorage<K, V> {
}
pub(super) struct StringArena {
pub(super) _data: FastVec<u8>,
pub(super) _offsets: FastVec<u32>,
pub(super) _interned: std::collections::HashMap<Vec<u8>, u32>,
}
pub(super) struct StringBucket {
pub(super) _hash: u64,
pub(super) _string_id: u32,
pub(super) _probe_distance: u16,
pub(super) _prefix_cache: u32,
}
pub(super) struct StringEntry<V> {
pub(super) _value: V,
pub(super) _next: Option<u32>,
}
pub(super) struct PrefixCacheEntry {
pub(super) _prefix: u64, pub(super) _string_id: u32,
}
pub(super) struct HashEntry<K, V> {
pub(super) key: Option<K>,
pub(super) value: Option<V>,
pub(super) hash: u64,
pub(super) _next: Option<u32>,
}