### Mphf::hash — Look up a known key Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Use `hash` to get the index for keys known to be in the set. If the item was not in the set, the function may return an arbitrary value or panic. ```rust use boomphf::Mphf; fn main() { let keys = vec!["apple", "banana", "cherry", "date"]; let phf = Mphf::new(1.7, &keys); // Each key maps to a unique index in 0..4 for key in &keys { let idx = phf.hash(key); println!("{} -> {}", key, idx); // e.g. "apple -> 2" assert!(idx < keys.len() as u64); } } ``` -------------------------------- ### Generate and Use Minimal Perfect Hash Function in Rust Source: https://github.com/10xgenomics/rust-boomphf/blob/master/README.md Demonstrates how to generate a minimal perfect hash function (MPHF) for a given set of objects and retrieve hash values. Ensure all objects to be hashed are part of the initial set used for MPHF creation. ```rust use boomphf::* // sample set of obejcts let possible_objects = vec![1, 10, 1000, 23, 457, 856, 845, 124, 912]; let n = possible_objects.len(); // generate a minimal perfect hash function of these items let phf = Mphf::new(1.7, possible_objects.clone(), None); // Get hash value of all objects let mut hashes = Vec::new(); for v in possible_objects { hashes.push(phf.hash(&v)); } hashes.sort(); // Expected hash output is set of all integers from 0..n let expected_hashes: Vec = (0 .. n as u64).collect(); assert!(hashes == expected_hashes) ``` -------------------------------- ### Build MPHF from In-Memory Slice Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Constructs an MPHF from a slice of keys. The `gamma` parameter ( > 1.01) balances construction time and memory footprint. Duplicate keys will cause a panic. ```rust use boomphf::Mphf; fn main() { let keys: Vec = vec![1, 10, 1000, 23, 457, 856, 845, 124, 912]; let n = keys.len(); // gamma = 1.7 is a balanced default let phf = Mphf::new(1.7, &keys); let mut hashes: Vec = keys.iter().map(|k| phf.hash(k)).collect(); hashes.sort_unstable(); // MPHFs always produce a permutation of 0..n let expected: Vec = (0..n as u64).collect(); assert_eq!(hashes, expected); println!("All hashes: {:?}", hashes); // [0, 1, 2, 3, 4, 5, 6, 7, 8] } ``` -------------------------------- ### Mphf::new Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Constructs a minimal perfect hash function from an in-memory slice of objects. The `gamma` parameter controls the trade-off between construction time and memory footprint. Duplicate keys are not allowed and will cause a panic. ```APIDOC ## Mphf::new ### Description Constructs a minimal perfect hash function from a slice of objects. The `gamma` parameter (must be > 1.01) controls the trade-off between construction time and the memory footprint of the resulting structure; a value of `1.7` is a good default. Duplicate keys are not allowed and will cause a panic after `MAX_ITERS` (100) failed rounds. ### Method `Mphf::new(gamma: f64, keys: &[T]) -> Self` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust use boomphf::Mphf; let keys: Vec = vec![1, 10, 1000, 23, 457, 856, 845, 124, 912]; let phf = Mphf::new(1.7, &keys); let hash_value = phf.hash(&1000); ``` ### Response #### Success Response (Self) Returns a constructed `Mphf` instance. #### Response Example ```rust // Example usage demonstrating hash output let hashes: Vec = keys.iter().map(|k| phf.hash(k)).collect(); ``` ``` -------------------------------- ### NoKeyBoomHashMap2::new Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Constructs a memory-optimal dual-value map without storing keys. This combines the space savings of `NoKeyBoomHashMap` with the two-value-column layout of `BoomHashMap2`. Keys must be externally validated before querying. ```APIDOC ## `NoKeyBoomHashMap2::new` — Memory-optimal dual-value map without stored keys Combines the no-key memory savings of `NoKeyBoomHashMap` with the two-value-column layout of `BoomHashMap2`. Keys must be externally validated before querying; a parallel constructor `NoKeyBoomHashMap2::new_parallel` is also available. ### Usage ```rust use boomphf::hashmap::NoKeyBoomHashMap2; let keys: Vec = vec![100, 200, 300, 400]; let offsets: Vec = vec![0, 128, 256, 512]; let lengths: Vec = vec![64, 64, 128, 32]; let map = NoKeyBoomHashMap2::new(keys.clone(), offsets, lengths); // Query only with known keys for k in &keys { if let Some((off, len)) = map.get(k) { println!("key={} offset={} length={}", k, off, len); } } ``` ``` -------------------------------- ### Parallel MPHF Construction Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Constructs an MPHF in parallel using the Rayon thread pool. Requires the `parallel` feature. An optional `starting_seed` can shift internal hash seeds. ```rust // Cargo.toml: boomphf = { version = "0.6", features = ["parallel"] } use boomphf::Mphf; fn main() { let items: Vec = (0..1_000_000_u64).map(|x| x * 2).collect(); // None = use seed 0; pass Some(42) to start from a different seed let phf = Mphf::new_parallel(1.7, &items, None); // Verify a few lookups assert_eq!(phf.hash(&0_u64), phf.hash(&0_u64)); // deterministic let h = phf.hash(&1_000_u64); assert!(h < 1_000_000); // always in 0..n println!("hash(1000) = {}", h); } ``` -------------------------------- ### Memory-Efficient MPHF from Chunked Iterator Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Builds an MPHF without loading all keys into memory. Iterates over chunks multiple times; inner iterators must be `ExactSizeIterator`. `n` is the total number of keys. ```rust use boomphf::Mphf; fn main() { // Simulate keys split across multiple on-disk shards let chunk_a: Vec = (0..500).collect(); let chunk_b: Vec = (500..1000).collect(); let chunks = vec![chunk_a, chunk_b]; let total: u64 = 1000; let phf = Mphf::from_chunked_iterator(1.7, &chunks, total); let mut hashes: Vec = chunks .iter() .flat_map(|c| c.iter().map(|k| phf.hash(k))) .collect(); hashes.sort_unstable(); let expected: Vec = (0..total).collect(); assert_eq!(hashes, expected); println!("Chunked MPHF built for {} keys", total); } ``` -------------------------------- ### Serde Serialization/Deserialization Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt All public types derive `serde::Serialize` and `serde::Deserialize` when the `serde` Cargo feature is enabled, allowing MPHFs and hash maps to be persisted and reloaded without reconstruction. ```APIDOC ## Serde serialization / deserialization All public types derive `serde::Serialize` and `serde::Deserialize` when the `serde` Cargo feature is enabled, allowing MPHFs and hash maps to be persisted to disk and reloaded without re-construction. ### Usage ```rust // Cargo.toml: boomphf = { version = "0.6", features = ["serde"] } // [dependencies] // serde_json = "1" use boomphf::Mphf; let keys: Vec = (0..1000).collect(); let phf = Mphf::new(1.7, &keys); // Serialize to JSON (or any serde format) let json = serde_json::to_string(&phf).expect("serialize failed"); println!("serialized size: {} bytes", json.len()); // Deserialize and verify round-trip let phf2: Mphf = serde_json::from_str(&json).expect("deserialize failed"); for k in &keys { assert_eq!(phf.hash(k), phf2.hash(k)); } println!("Round-trip OK"); ``` ``` -------------------------------- ### Create NoKeyBoomHashMap2 Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Use NoKeyBoomHashMap2 for a dual-value map without stored keys, offering memory savings similar to NoKeyBoomHashMap. Keys must be externally validated before querying. ```rust use boomphf::hashmap::NoKeyBoomHashMap2; fn main() { let keys: Vec = vec![100, 200, 300, 400]; let offsets: Vec = vec![0, 128, 256, 512]; let lengths: Vec = vec![64, 64, 128, 32]; let map = NoKeyBoomHashMap2::new(keys.clone(), offsets, lengths); // Query only with known keys for k in &keys { if let Some((off, len)) = map.get(k) { println!("key={} offset={} length={}", k, off, len); } } } ``` -------------------------------- ### Create NoKeyBoomHashMap Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Use NoKeyBoomHashMap when keys are large and only known keys will be queried. Querying unknown keys returns a random value without a membership check. ```rust use boomphf::hashmap::NoKeyBoomHashMap; fn main() { // Suppose genome k-mer strings — keys are large; we never query unknown k-mers let kmers: Vec<&str> = vec!["ACGT", "TGCA", "GGCC", "ATAT"]; let counts: Vec = vec![42, 17, 88, 5]; let map = NoKeyBoomHashMap::new(kmers.clone(), counts); // Safe only because we query known keys for kmer in &kmers { println!("{} -> {:?}", kmer, map.get(*kmer)); } // e.g. ACGT -> Some(42) } ``` -------------------------------- ### Mphf::try_hash — Safe lookup for potentially unknown keys Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Use `try_hash` for safe lookups when key membership is uncertain. It returns `Some(index)` if the slot is occupied (key may be present) or `None` if the slot is empty. ```rust use boomphf::Mphf; fn main() { let keys: Vec = vec![10, 20, 30, 40, 50]; let phf = Mphf::new(1.7, &keys); // Key in set match phf.try_hash(&30_i32) { Some(idx) => println!("30 -> slot {}", idx), None => println!("30 not found"), } // Key NOT in set — returns Some with arbitrary value or None match phf.try_hash(&99_i32) { Some(idx) => println!("99 spuriously mapped to slot {}", idx), None => println!("99 -> None (lucky miss)"), } } ``` -------------------------------- ### BoomHashMap::new_parallel Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Constructs a `BoomHashMap` in parallel using Rayon. This is an optimization for large datasets and requires the `parallel` feature to be enabled. ```APIDOC ## `BoomHashMap::new_parallel` — Parallel construction of a key-value map Identical to `BoomHashMap::new` but constructs the underlying MPHF in parallel via Rayon. Requires the `parallel` feature. ### Method ```rust fn new_parallel(keys: Vec, values: Vec) -> Self ``` ### Parameters - **keys** (*Vec*): A vector of keys. - **values** (*Vec*): A vector of corresponding values. ### Returns - **Self**: A new `BoomHashMap` instance constructed in parallel. ``` -------------------------------- ### FromIterator Adapters Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt All four map types implement `FromIterator`, allowing idiomatic construction from iterator chains. This enables creating maps from collections or other iterators. ```APIDOC ## `FromIterator` adapters — Construct maps from iterators All four map types implement `FromIterator`, enabling idiomatic collection from iterator chains. ### Usage ```rust use boomphf::hashmap::{BoomHashMap, BoomHashMap2, NoKeyBoomHashMap}; // BoomHashMap from (key, value) pairs let map: BoomHashMap = vec![(1, "one"), (2, "two"), (3, "three")] .into_iter() .collect(); assert_eq!(map.get(&2), Some(&"two")); // BoomHashMap2 from (key, v1, v2) triples let map2: BoomHashMap2 = vec![(10, 1.0, true), (20, 2.0, false)] .into_iter() .collect(); assert_eq!(map2.get(&10), Some((&1.0_f32, &true))); // NoKeyBoomHashMap from (key, value) pairs let nokey: NoKeyBoomHashMap = vec![(5, 25), (6, 36), (7, 49)] .into_iter() .collect(); assert_eq!(nokey.get(&6), Some(&36)); ``` ``` -------------------------------- ### BoomHashMap::new Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Creates a new key-value map backed by an MPHF. Keys and values are stored in parallel vectors, ordered such that `keys[mphf.hash(k)] == k`. This ensures safe lookups by verifying the stored key. ```APIDOC ## `BoomHashMap::new` — Key-value map backed by an MPHF Stores keys and values in two parallel dense `Vec`s ordered by the MPHF. Construction reorders the input arrays in place so that `keys[mphf.hash(k)] == k`. Lookups verify the stored key to reject unknown queries, making this safe to use with arbitrary query keys. ### Method ```rust fn new(keys: Vec, values: Vec) -> Self ``` ### Parameters - **keys** (*Vec*): A vector of keys. - **values** (*Vec*): A vector of corresponding values. ### Returns - **Self**: A new `BoomHashMap` instance. ``` -------------------------------- ### Parallel Chunked MPHF Construction Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Parallelizes chunked MPHF construction using `crossbeam`. Suitable for very large datasets needing memory and CPU efficiency. `max_iters` limits construction rounds. ```rust // Cargo.toml: boomphf = { version = "0.6", features = ["parallel"] } use boomphf::Mphf; fn main() { let chunks: Vec> = (0..8) .map(|i| (i * 125_000..(i + 1) * 125_000).collect()) .collect(); let total: u64 = 1_000_000; let phf = Mphf::from_chunked_iterator_parallel( 1.7, &chunks, None, // max_iters: no limit total, 4, // num_threads ); let h = phf.hash(&500_000_u64); assert!(h < total); println!("Parallel chunked hash(500000) = {}", h); } ``` -------------------------------- ### Serde Serialization and Deserialization of Mphf Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Persist and reload MPHFs using Serde when the `serde` Cargo feature is enabled. This allows for efficient loading of pre-built structures. ```rust // Cargo.toml: boomphf = { version = "0.6", features = ["serde"] } // [dependencies] serde_json = "1" use boomphf::Mphf; fn main() { let keys: Vec = (0..1000).collect(); let phf = Mphf::new(1.7, &keys); // Serialize to JSON (or any serde format) let json = serde_json::to_string(&phf).expect("serialize failed"); println!("serialized size: {} bytes", json.len()); // Deserialize and verify round-trip let phf2: Mphf = serde_json::from_str(&json).expect("deserialize failed"); for k in &keys { assert_eq!(phf.hash(k), phf2.hash(k)); } println!("Round-trip OK"); } ``` -------------------------------- ### NoKeyBoomHashMap::new Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Constructs a memory-optimal map without storing keys. Querying unknown keys returns a random value, so keys must be validated externally before querying. ```APIDOC ## `NoKeyBoomHashMap::new` — Memory-optimal map without stored keys Keys are *not* stored after construction, making this map significantly smaller when keys are large (e.g., long strings or large structs) and the caller can guarantee that only construction-set keys will be queried. Querying an unknown key silently returns a random value — there is no membership check. ### Usage ```rust use boomphf::hashmap::NoKeyBoomHashMap; let kmers: Vec<&str> = vec!["ACGT", "TGCA", "GGCC", "ATAT"]; let counts: Vec = vec![42, 17, 88, 5]; let map = NoKeyBoomHashMap::new(kmers.clone(), counts); // Safe only because we query known keys for kmer in &kmers { println!("{:?} -> {:?}", kmer, map.get(*kmer)); } // e.g. ACGT -> Some(42) ``` ``` -------------------------------- ### Mphf::new_parallel Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Constructs a minimal perfect hash function in parallel using the Rayon thread pool. This method is suitable for large datasets where performance is critical. An optional `starting_seed` can be provided to shift internal hash seeds. ```APIDOC ## Mphf::new_parallel ### Description Same semantics as `Mphf::new` but distributes work across the default Rayon thread pool. Requires the `parallel` feature (enabled by default). The optional `starting_seed` shifts the internal hash seeds, which can be useful when composing multiple MPHFs. ### Method `Mphf::new_parallel(gamma: f64, keys: &[T], starting_seed: Option) -> Self` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust // Cargo.toml: boomphf = { version = "0.6", features = ["parallel"] } use boomphf::Mphf; let items: Vec = (0..1_000_000_u64).map(|x| x * 2).collect(); let phf = Mphf::new_parallel(1.7, &items, None); // Use default seed let hash_value = phf.hash(&1000_u64); ``` ### Response #### Success Response (Self) Returns a constructed `Mphf` instance using parallel processing. #### Response Example ```rust // Example usage demonstrating hash output assert!(phf.hash(&1_000_u64) < 1_000_000); ``` ``` -------------------------------- ### BoomHashMap::new — Key-value map backed by an MPHF Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Constructs a key-value map using an MPHF. Keys are reordered in place to ensure `keys[mphf.hash(k)] == k`. Lookups verify the stored key for safety. ```rust use boomphf::hashmap::BoomHashMap; fn main() { let keys = vec!["one", "two", "three", "four", "five"]; let values = vec![1_u32, 2, 3, 4, 5]; let map = BoomHashMap::new(keys, values); // Successful lookup assert_eq!(map.get("three"), Some(&3)); println!("three = {:?}", map.get("three")); // Some(3) // Unknown key returns None assert_eq!(map.get("six"), None); // Iterate all pairs for (k, v) in map.iter() { println!("{} => {}", k, v); } println!("total entries: {}", map.len()); } ``` -------------------------------- ### BoomHashMap2::new Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Creates a `BoomHashMap2` which associates each key with two independent value arrays. This structure is optimized to reduce padding overhead when value types have incompatible alignment. A parallel variant `new_parallel` is also available. ```APIDOC ## `BoomHashMap2::new` — Dual-value map backed by an MPHF Like `BoomHashMap` but associates each key with *two* independent value arrays (`D1` and `D2`). This avoids the struct/tuple padding overhead when the two value types have incompatible alignment. Parallel variant `BoomHashMap2::new_parallel` is also available. ### Method ```rust fn new(keys: Vec, values1: Vec, values2: Vec) -> Self ``` ### Parameters - **keys** (*Vec*): A vector of keys. - **values1** (*Vec*): The first vector of values. - **values2** (*Vec*): The second vector of values. ### Returns - **Self**: A new `BoomHashMap2` instance. ``` -------------------------------- ### BoomHashMap::new_parallel — Parallel construction of a key-value map Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Constructs a `BoomHashMap` in parallel using Rayon. Requires the `parallel` feature to be enabled in `Cargo.toml`. ```rust // Cargo.toml: boomphf = { version = "0.6", features = ["parallel"] } use boomphf::hashmap::BoomHashMap; fn main() { let keys: Vec = (0..100_000).collect(); let values: Vec = (0..100_000).map(|x| x * x).collect(); let map = BoomHashMap::new_parallel(keys, values); assert_eq!(map.get(&42_u64), Some(&1764_u64)); println!("42² = {:?}", map.get(&42_u64)); // Some(1764) } ``` -------------------------------- ### Mphf::from_chunked_iterator Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Builds an MPHF from chunked data without holding all keys in memory simultaneously. The outer collection is iterated multiple times, and inner iterators must implement `ExactSizeIterator`. ```APIDOC ## Mphf::from_chunked_iterator ### Description Builds an MPHF without holding all keys in memory simultaneously. The outer collection is iterated multiple times; the inner iterators must implement `ExactSizeIterator` so the algorithm can skip ahead efficiently. `n` is the total number of keys across all chunks. ### Method `Mphf::from_chunked_iterator(gamma: f64, chunks: &[I], n: u64) -> Self` where `I: AsRef<[T]> + ExactSizeIterator` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust use boomphf::Mphf; let chunk_a: Vec = (0..500).collect(); let chunk_b: Vec = (500..1000).collect(); let chunks = vec![chunk_a, chunk_b]; let total: u64 = 1000; let phf = Mphf::from_chunked_iterator(1.7, &chunks, total); let hash_value = phf.hash(&750_u32); ``` ### Response #### Success Response (Self) Returns a constructed `Mphf` instance from chunked data. #### Response Example ```rust // Example usage demonstrating hash output let mut hashes: Vec = chunks.iter().flat_map(|c| c.iter().map(|k| phf.hash(k))).collect(); hashes.sort_unstable(); let expected: Vec = (0..total).collect(); assert_eq!(hashes, expected); ``` ``` -------------------------------- ### Mphf::try_hash Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Safely attempts to find the hash index for a key. Returns `Some(index)` if the slot is occupied (key *may* be in the set), or `None` if the slot is empty. Note that `Some` does not guarantee key membership. ```APIDOC ## `Mphf::try_hash` — Safe lookup for potentially unknown keys Returns `Some(index)` when the hash slot is occupied (the item *may* be in the set) or `None`. Because an MPHF does not store keys, a returned `Some` value is not a guarantee of membership — callers that need hard membership checks must maintain an auxiliary key list (as `BoomHashMap` does). ### Method ```rust fn try_hash(&self, key: &K) -> Option ``` ### Parameters - **key** (*&K*): The key to look up. ### Returns - **Option**: `Some(index)` if the slot is occupied, `None` otherwise. ``` -------------------------------- ### Mphf::hash Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Looks up the hash index for a known key. Use `try_hash` when membership is uncertain, as this function may return arbitrary values or panic for unknown keys. ```APIDOC ## `Mphf::hash` — Look up a known key Returns the `u64` hash index (in `0..n`) for an item that was present in the construction set. If the item was *not* in the set, the function may return an arbitrary value or panic — use `try_hash` when membership is uncertain. ### Method ```rust fn hash(&self, key: &K) -> u64 ``` ### Parameters - **key** (*&K*): The key to hash. ### Returns - **u64**: The hash index of the key. ``` -------------------------------- ### Construct Maps from Iterators using FromIterator Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Idiomatic construction of various map types from iterator chains using the `FromIterator` trait. ```rust use boomphf::hashmap::{BoomHashMap, BoomHashMap2, NoKeyBoomHashMap}; fn main() { // BoomHashMap from (key, value) pairs let map: BoomHashMap = vec![(1, "one"), (2, "two"), (3, "three")] .into_iter() .collect(); assert_eq!(map.get(&2), Some(&"two")); // BoomHashMap2 from (key, v1, v2) triples let map2: BoomHashMap2 = vec![(10, 1.0, true), (20, 2.0, false)] .into_iter() .collect(); assert_eq!(map2.get(&10), Some((&1.0_f32, &true))); // NoKeyBoomHashMap from (key, value) pairs let nokey: NoKeyBoomHashMap = vec![(5, 25), (6, 36), (7, 49)] .into_iter() .collect(); assert_eq!(nokey.get(&6), Some(&36)); } ``` -------------------------------- ### Mphf::from_chunked_iterator_parallel Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Parallelises `from_chunked_iterator` over a configurable number of threads using `crossbeam`. Suitable for very large datasets where both memory and CPU efficiency matter. `max_iters` bounds the number of construction rounds. ```APIDOC ## Mphf::from_chunked_iterator_parallel ### Description Parallelises `from_chunked_iterator` over a configurable number of threads using `crossbeam`. Suitable for very large datasets where both memory and CPU efficiency matter. `max_iters` bounds the number of construction rounds (pass `None` for unlimited). ### Method `Mphf::from_chunked_iterator_parallel(gamma: f64, chunks: &[I], max_iters: Option, n: u64, num_threads: usize) -> Self` where `I: AsRef<[T]> + ExactSizeIterator` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust // Cargo.toml: boomphf = { version = "0.6", features = ["parallel"] } use boomphf::Mphf; let chunks: Vec> = (0..8).map(|i| (i * 125_000..(i + 1) * 125_000).collect()).collect(); let total: u64 = 1_000_000; let phf = Mphf::from_chunked_iterator_parallel(1.7, &chunks, None, total, 4); let hash_value = phf.hash(&500_000_u64); ``` ### Response #### Success Response (Self) Returns a constructed `Mphf` instance using parallel chunked construction. #### Response Example ```rust // Example usage demonstrating hash output assert!(phf.hash(&500_000_u64) < 1_000_000); ``` ``` -------------------------------- ### BoomHashMap2::new — Dual-value map backed by an MPHF Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Associates each key with two independent value arrays, useful for avoiding struct padding overhead. A parallel variant `BoomHashMap2::new_parallel` is also available. ```rust use boomphf::hashmap::BoomHashMap2; fn main() { let keys: Vec<&str> = vec!["a", "b", "c"]; let scores: Vec = vec![0.9, 0.5, 0.7]; let counts: Vec = vec![10, 5, 8]; let map = BoomHashMap2::new(keys, scores, counts); match map.get("b") { Some((score, count)) => println!("b: score={}, count={}", score, count), None => println!("not found"), } // Output: b: score=0.5, count=5 } ``` -------------------------------- ### BoomHashMap::get_key_id Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Retrieves the internal array position (index) of a key if it exists in the map. Returns `None` if the key is not found. This is useful for obtaining a stable identifier for keys. ```APIDOC ## `BoomHashMap::get_key_id` — Retrieve the dense array position of a key Returns the position (`usize`) of the key inside the internal array if the key is present, or `None` otherwise. This is useful when you need a stable integer identifier for each key — the same integer used to index auxiliary data stored externally. ### Method ```rust fn get_key_id(&self, key: &K) -> Option ``` ### Parameters - **key** (*&K*): The key to find the ID for. ### Returns - **Option**: The position of the key if found, otherwise `None`. ``` -------------------------------- ### BoomHashMap::get_key_id — Retrieve the dense array position of a key Source: https://context7.com/10xgenomics/rust-boomphf/llms.txt Returns the stable integer identifier (position) of a key within the internal array if present, otherwise `None`. This is useful for indexing auxiliary data structures. ```rust use boomphf::hashmap::BoomHashMap; fn main() { let keys = vec!["alpha", "beta", "gamma"]; let values = vec![100_i32, 200, 300]; let map = BoomHashMap::new(keys, values); if let Some(id) = map.get_key_id("beta") { println!("'beta' is at position {}", id); // Use id to index into an external auxiliary array } assert_eq!(map.get_key_id("delta"), None); // unknown key } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.