pub struct PartitionedMphf { /* private fields */ }Expand description
A partitioned minimal perfect hash function.
Splits keys into partitions by hash range (Lemire fast-range reduction),
builds one PHast MPHF per partition, and routes queries transparently.
Global indices are offsets[partition] + inner_mphf.get(key).
Implementations§
Source§impl PartitionedMphf
impl PartitionedMphf
Sourcepub fn build_from_vec<K: Hash + Clone + Send + Sync>(
keys: Vec<K>,
partitioned: bool,
) -> Self
pub fn build_from_vec<K: Hash + Clone + Send + Sync>( keys: Vec<K>, partitioned: bool, ) -> Self
Build a partitioned MPHF from an owned Vec of keys.
If partitioned is false (or there are fewer than AVG_PARTITION_SIZE
keys), a single partition is used — equivalent to a monolithic MPHF with
zero query overhead.
Sourcepub fn build_from_slice<K: Hash + Clone + Send + Sync>(
keys: &[K],
partitioned: bool,
) -> Self
pub fn build_from_slice<K: Hash + Clone + Send + Sync>( keys: &[K], partitioned: bool, ) -> Self
Build a partitioned MPHF from a slice of keys (clones into Vec).
Sourcepub fn get<K: Hash + ?Sized>(&self, key: &K) -> usize
pub fn get<K: Hash + ?Sized>(&self, key: &K) -> usize
Look up a key and return its global index in [0, num_keys).
For keys NOT in the build set, returns num_keys (out-of-range sentinel).
The COMBINE-lab ph fork returns usize::MAX for keys that exhaust all
levels without matching, which we map to num_keys.
Sourcepub fn num_partitions(&self) -> u32
pub fn num_partitions(&self) -> u32
Number of partitions.
Sourcepub fn write_bytes(&self) -> usize
pub fn write_bytes(&self) -> usize
Estimate serialized byte size (for container offset table pre-allocation).
Auto Trait Implementations§
impl Freeze for PartitionedMphf
impl RefUnwindSafe for PartitionedMphf
impl Send for PartitionedMphf
impl Sync for PartitionedMphf
impl Unpin for PartitionedMphf
impl UnsafeUnpin for PartitionedMphf
impl UnwindSafe for PartitionedMphf
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more