PairedVerifiedConstMap, a cache-friendlier layout for the verified map, and file formats shared with the Rust and Python implementations.
This release is purely additive. Nothing was removed or renamed, and the CMAP0001 and VMAP0001 formats are byte-for-byte unchanged, so anything written by v1.0.x or v1.1.0 still loads and anything this version writes still loads there.
PairedVerifiedConstMap
VerifiedConstMap keeps values and fingerprints in two arrays, so a lookup of a present key touches six cache lines. PairedVerifiedConstMap stores each value next to its fingerprint: three cache lines.
pm, err := constmap.NewPaired(keys, values)
pm.Map("banana") // 200
pm.Map("grape") // constmap.NotFoundSame semantics, same ~18 bytes/key, same API (Map, MapMany, MapManyInto, SaveToFile, LoadPairedFromFile); an existing map converts with vm.Paired(). It is faster when the keys you look up are usually present (random lookups over a million keys: about 6% on an Intel Xeon Gold 6548N while the map sits in cache, 19% at ten million keys where it does not; MapMany 27% faster cold) and slower for absent keys, since the split layout stops after its half-size fingerprint array. The README has the numbers and the guidance.
On amd64 and arm64, MapMany resolves each block of eight keys with a small assembly gather (SSE2 / NEON). -tags purego gives the portable Go version.
Interoperability
The formats are shared with rsconstmap 0.3 and fastconstmap 0.10: a map saved by any of the three loads in the other two, on a little-endian host. This package and rsconstmap write byte-identical files; fastconstmap adds a key count in a header word the readers ignore, and writes its ConstMap as CMAP0003, which ReadFrom now accepts. Files written by the other implementations live under testdata/interop and are checked by the test suite.
Also
- A CI workflow on x64 and arm64, with and without
purego. ReadFromnames aVerifiedConstMaporPairedVerifiedConstMapfile handed to the wrong loader, and a legacy fastconstmap file whose key hash differs.