Skip to content

"Subkey" concept is undocumented #425

@sjakobi

Description

@sjakobi

There are two constants named using this term, but I can't find any other use of it in Bagwell's paper or the context of HAMTs.

bitsPerSubkey :: Int
bitsPerSubkey = 5

subkeyMask :: Bitmap
subkeyMask = 1 `unsafeShiftL` bitsPerSubkey - 1

From this context I suspect that a subkey is a 5-bit part of a hash. I.e. a 64-bit or 32-bit hash can be understood as a sequence of subkeys. For example:

hash32 = 0b10_00101_00100_00011_00010_00001_00000
subkeys(hash32) = [0b00000, 0b00001, 0b00010, 0b00011, 0b00100, 0b00101, 0b10]

Subsequent subkeys of a given hash are used to navigate the tree at subsequent levels:

index(hash, shift) = subkeys(hash) !! (shift / bitsPerSubkey)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions