Bloom filter
Every SEAM data file has a bloom frame. It is a split-block Bloom filter over user keys; timestamps are excluded. The code is in crates/strata-lsm/src/bloom.rs. The frame is always stored raw (see Frame), and its position is given by bloom_off and bloom_len in the footer.
Algorithm
Section titled “Algorithm”- The hash is
h = xxh3_64(user_key)(seed 0). Consecutive duplicate hashes are added once, andkeysbelow counts the hashes that were added. - The filter is
blocks * 32bytes. Each block is 256 bits, stored as 8 little-endian u32 words. blocks = ceil(max(keys * bits_per_key, 256) / 256).bits_per_keyis 10 (SPEC V52 requires at least 10). Large files pre-size from the expected key count (65536 keys or more).- The block of
his((h >> 32) * blocks) >> 32. - For each word
iin 0 to 7, the bit is(lo32(h) * SALT[i]) >> 27, using a 32-bit wrapping multiply.
SALT = [0x47b6137b, 0x44974d91, 0x8824ad5b, 0xa2b7289d, 0x705495c7, 0x2df1424b, 0x9efc4947, 0x5c6bfb31]may_contain
Section titled “may_contain”may_contain is true if and only if all 8 selected bits are set. An empty filter (0 blocks) admits everything.
After the bits, the frame may carry a tail naming keys that were deliberately not added. The footer flags say which layout applies.
| Flags | Raw layout | Meaning |
|---|---|---|
| neither | bits |
plain |
BLOOM_SKIP only |
bits ‖ tags ‖ n_tags u8 |
skip tail |
BLOOM_SKIP and BLOOM_RANGES |
bits ‖ n_tags u8 ‖ tags ‖ (len u8 ‖ prefix)* ‖ body_len u32 LE |
ranged tail |
A malformed tail is Corrupt("bloom skip").
What the SQL layer registers
Section titled “What the SQL layer registers”- Skip tag
0x02: non-unique index entries are only range-scanned. - Bloom-off prefixes
0x01 ‖ root_table_id u32 BEfor tables createdWITH (bloom = off), see Ext B: bloom off.