Skip to main content

FlashMap

Struct FlashMap 

Source
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 values
  • FlashMap<[u8; 32], [u8; 32]> — hash → hash mappings

Implementations§

Source§

impl<K: PodBound + Send + Sync, V: PodBound + Send + Sync> FlashMap<K, V>

Source

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.

Source

pub fn builder(capacity: usize) -> FlashMapBuilder

Create a builder for fine-grained configuration.

Source

pub fn bulk_get(&self, keys: &[K]) -> Result<Vec<Option<V>>, FlashMapError>

Look up multiple keys in parallel. Returns None for missing keys.

Source

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).

Source

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.

Source

pub fn len(&self) -> usize

Number of occupied entries.

Source

pub fn is_empty(&self) -> bool

Whether the map is empty.

Source

pub fn capacity(&self) -> usize

Total slot capacity (always a power of 2).

Source

pub fn load_factor(&self) -> f64

Current load factor (0.0 to 1.0).

Source

pub fn clear(&mut self) -> Result<(), FlashMapError>

Remove all entries, resetting to empty.

Trait Implementations§

Source§

impl<K: PodBound + Send + Sync, V: PodBound + Send + Sync> Debug for FlashMap<K, V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<K, V> !Freeze for FlashMap<K, V>

§

impl<K, V> RefUnwindSafe for FlashMap<K, V>

§

impl<K, V> Send for FlashMap<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for FlashMap<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for FlashMap<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnsafeUnpin for FlashMap<K, V>

§

impl<K, V> UnwindSafe for FlashMap<K, V>
where K: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.