pub struct FlashMap<K: PodBound, V: PodBound> { /* private fields */ }Expand description
GPU-native concurrent hash map with bulk-only operations.
Generic over fixed-size key K and value V types that implement
bytemuck::Pod (plain old data — Copy, fixed layout, any bit
pattern valid).
Common type combinations:
FlashMap<[u8; 32], [u8; 128]>— blockchain state (pubkey → account)FlashMap<u64, u64>— numeric keys and valuesFlashMap<[u8; 32], [u8; 32]>— hash → hash mappings
Implementations§
Source§impl<K: PodBound + Send + Sync, V: PodBound + Send + Sync> FlashMap<K, V>
impl<K: PodBound + Send + Sync, V: PodBound + Send + Sync> FlashMap<K, V>
Sourcepub fn with_capacity(capacity: usize) -> Result<Self, FlashMapError>
pub fn with_capacity(capacity: usize) -> Result<Self, FlashMapError>
Create a FlashMap with the given capacity using default settings.
Tries GPU first (if cuda feature enabled), falls back to CPU.
Capacity is rounded up to the next power of 2.
Sourcepub fn builder(capacity: usize) -> FlashMapBuilder
pub fn builder(capacity: usize) -> FlashMapBuilder
Create a builder for fine-grained configuration.
Sourcepub fn bulk_get(&self, keys: &[K]) -> Result<Vec<Option<V>>, FlashMapError>
pub fn bulk_get(&self, keys: &[K]) -> Result<Vec<Option<V>>, FlashMapError>
Look up multiple keys in parallel. Returns None for missing keys.
Sourcepub fn bulk_insert(&mut self, pairs: &[(K, V)]) -> Result<usize, FlashMapError>
pub fn bulk_insert(&mut self, pairs: &[(K, V)]) -> Result<usize, FlashMapError>
Insert multiple key-value pairs in parallel.
Returns the number of new insertions (updates don’t count). If a key already exists, its value is updated in place.
§Invariant
No duplicate keys within a single batch. If the same key appears multiple times, behavior is undefined (one will win, but which one is non-deterministic on GPU).
Sourcepub fn bulk_remove(&mut self, keys: &[K]) -> Result<usize, FlashMapError>
pub fn bulk_remove(&mut self, keys: &[K]) -> Result<usize, FlashMapError>
Remove multiple keys in parallel (tombstone-based).
Returns the number of keys actually removed.
Sourcepub fn load_factor(&self) -> f64
pub fn load_factor(&self) -> f64
Current load factor (0.0 to 1.0). Max allowed is 0.5.
Sourcepub fn clear(&mut self) -> Result<(), FlashMapError>
pub fn clear(&mut self) -> Result<(), FlashMapError>
Remove all entries, resetting to empty.