Skip to main content

Crate matchy_literal_hash

Crate matchy_literal_hash 

Source
Expand description

Literal String Hash Table for O(1) Lookups

Memory-mapped hash table for exact string matching. Uses 96-bit XXH3 hashes (stored as u64 + u32) with sharded parallel construction and linear probing.

§Format (Version 3)

[Header - 32 bytes]
  magic: [u8; 4]           // "LHSH"
  version: u32             // 3
  entry_count: u32         // Number of literal patterns
  table_size: u32          // Hash table size (slots)
  num_shards: u32          // Number of shards (power of 2)
  shard_bits: u32          // Bits for sharding (log2(num_shards))
  mappings_offset: u32     // Offset to pattern mappings
  table_offset: u32        // 8-byte aligned offset to hash table

[Shard Offset Table]
  offsets: [u32; num_shards + 1]

[Hash Table - Array of Structs]
  entries: [HashEntry; table_size]
    hash_lo: u64           // Lower 64 bits of XXH3
    hash_hi: u32           // Upper 32 bits of XXH3
    pattern_id: u32        // Pattern ID for data lookup

[Pattern Mappings]
  count: u32
  mappings: [(pattern_id: u32, data_offset: u32); count]

Re-exports§

pub use validation::validate_literal_hash;
pub use validation::LiteralHashStats;
pub use validation::LiteralHashValidationResult;

Modules§

validation

Structs§

HashEntry
LiteralHash
LiteralHashBuilder
LiteralHashHeader

Enums§

LiteralHashError

Constants§

LITERAL_HASH_MAGIC
MATCHY_LITERAL_HASH_VERSION