hmap.bend checks
raw source on the hub · import bend-bpe-tokenizer@0.1.0.0/hmap.bend as Hmap
A String -> U32 map built in parallel: entries go to one of 2^depth buckets by their key's FNV-1a hash, a bit a level, the two halves of each level built at the same time, and each bucket is a Base Map. 0 means absent, as Map.get with default 0 answers.
1 import
import Base
Types
type HM source · line 6 · raw
Data
HLeaf@m:Map<&2, U32> -> HM
HNode@l:HM -> @r:HM -> HM
type HE source · line 10 · raw
Data
HE@h:U32 -> @k:String -> @v:U32 -> HE
type ETr source · line 54 · raw
Data
entries in a tree of lists, as a parallel build of them gives them
TLeaf@es:List<&2, HE> -> ETr
TNode@l:ETr -> @r:ETr -> ETr
Definitions
def hash_go source · line 13 · raw
@s:String -> @+h:U32 -> U32
def hash source · line 20 · raw
@s:String -> U32
def entry source · line 23 · raw
@+k:String -> @v:U32 -> HE
def fill source · line 26 · raw
@es:List<&2, HE> -> @m:Map<&2, U32> -> Map<&2, U32>
def he_bit source · line 33 · raw
@e:HE -> @+bit:U32 -> Bool
def keep_if source · line 38 · raw
@ok:Bool -> @e:HE -> @rest:List<&2, HE> -> List<&2, HE>
def keep source · line 46 · raw
@es:List<&2, HE> -> @+bit:U32 -> @+side:Bool -> List<&2, HE>
the entries whose hash bit is side
def flat_go source · line 58 · raw
@t:ETr -> @acc:List<&2, HE> -> List<&2, HE>
def flat source · line 65 · raw
@t:ETr -> List<&2, HE>
def build_go source · line 68 · raw
@depth:Nat -> @+bit:U32 -> @+es:List<&2, HE> -> HM
def build source · line 77 · raw
@+es:List<&2, HE> -> HM
a map of the entries, in 64 buckets
def side source · line 80 · raw
@right:Bool -> @go_l:(@_:Unit -> U32) -> @go_r:(@_:Unit -> U32) -> U32
def get_leaf source · line 87 · raw
@r:Pair(Map<&2, U32>, U32) -> U32
def get_go source · line 92 · raw
@m:HM -> @+h:U32 -> @+bit:U32 -> @+k:String -> U32
def get source · line 100 · raw
@m:HM -> @+k:String -> U32
the value of k, or 0
def pairs_go source · line 104 · raw
@m:HM -> @acc:List<&2, Sigma<&2, &2, String, _ => U32>> -> List<&2, Sigma<&2, &2, String, _ => U32>>
every entry, as (key, value) pairs
def pairs source · line 111 · raw
@m:HM -> List<&2, Sigma<&2, &2, String, _ => U32>>