Expand description
Bit-packed integer keys for multi-index maps. Bit-packed integer keys for multi-index maps.
A FlatIndexer turns a multi-index over fixed local dimensions into a
single integer key suitable for hashing. Dimension i occupies
ceil(log2(d_i)) bits at a fixed offset, so encoding is shift-and-OR with
no multiplication, and two multi-indices collide only if they are equal.
Widths up to 512 bits use fixed-width fast paths; wider index spaces fall back to a limb-backed representation with the same semantics.
The ladder stops at 512 bits. Since #1224 the 65..=512-bit arms are packed
digit by digit on the stack (see fixed) and converted to the arm’s type
once, so their encode cost no longer grows with the bignum’s digit count;
above 512 bits the key itself would need more inline space than a boxed
arm is worth, so wider index spaces use heap limbs.
The packers must stay inlined; see fixed for why that attribute is
load-bearing.
Structs§
- Flat
Indexer - Encodes multi-indices over fixed local dimensions as
IndexKeyvalues. - Index
Key - A bit-packed multi-index key.
- KeyBuilder
- Assembles one key by appending sub-keys at successive bit offsets.
Enums§
- Index
KeyError - Failures from index-key construction and encoding.
Functions§
- dimension_
bits - Number of bits needed to represent the values
0..dim. - total_
bits - Total bit width of the bit-packed key for
local_dims.