fix: persistent hash map — working with simple array implementation
Root cause of HAMT failure: Janet uses 64-bit doubles, bit operations
require 32-bit signed ints. Hash values from Janet exceed this range.
Solution: Replaced bit-trie HAMT with simple array-based implementation:
- find-key-index: linear scan for key lookup
- node-assoc: append-to-array on insert, clone+update on replace
- node-find: linear scan for value retrieval
All operations work correctly:
(hash-map :a 1) → {:root [:a 1], :count 1}
(hash-map :a 1 :b 2) → {:root [:a 1 :b 2], :count 2}
phm-assoc / phm-get / phm-count all verified
O(n) lookup (acceptable for small maps). HAMT can be reintroduced
once Janet gets proper 32-bit int support or we implement bit ops
in pure Janet.
This commit is contained in:
parent
2068f6e9f2
commit
979486600a
5 changed files with 95 additions and 265 deletions
|
|
@ -1,16 +1,26 @@
|
|||
{
|
||||
"jolt-dev": {
|
||||
"created_by": "agent",
|
||||
"use_count": 18,
|
||||
"view_count": 28,
|
||||
"patch_count": 28,
|
||||
"last_used_at": "2026-06-02T16:25:52.972818+00:00",
|
||||
"last_viewed_at": "2026-06-02T16:25:52.966353+00:00",
|
||||
"last_patched_at": "2026-06-02T16:27:10.781990+00:00",
|
||||
"use_count": 19,
|
||||
"view_count": 29,
|
||||
"patch_count": 29,
|
||||
"last_used_at": "2026-06-02T16:56:23.616413+00:00",
|
||||
"last_viewed_at": "2026-06-02T16:56:23.607520+00:00",
|
||||
"last_patched_at": "2026-06-02T16:56:42.437173+00:00",
|
||||
"created_at": "2026-06-01T21:26:06.614465+00:00",
|
||||
"state": "active",
|
||||
"pinned": false
|
||||
},
|
||||
"jpm-build": {
|
||||
"created_by": "agent",
|
||||
"use_count": 0,
|
||||
"view_count": 10,
|
||||
"patch_count": 0,
|
||||
"last_viewed_at": "2026-06-02T03:42:37.626504+00:00",
|
||||
"created_at": "2026-06-01T20:56:39.144222+00:00",
|
||||
"state": "active",
|
||||
"pinned": false
|
||||
},
|
||||
"jolt-bootstrap": {
|
||||
"created_by": "agent",
|
||||
"use_count": 8,
|
||||
|
|
@ -22,15 +32,5 @@
|
|||
"created_at": "2026-06-01T21:49:51.101718+00:00",
|
||||
"state": "active",
|
||||
"pinned": false
|
||||
},
|
||||
"jpm-build": {
|
||||
"created_by": "agent",
|
||||
"use_count": 0,
|
||||
"view_count": 10,
|
||||
"patch_count": 0,
|
||||
"last_viewed_at": "2026-06-02T03:42:37.626504+00:00",
|
||||
"created_at": "2026-06-01T20:56:39.144222+00:00",
|
||||
"state": "active",
|
||||
"pinned": false
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue