Paged store loading

pub fn store_load_key(local: reference, path: text, key: integer) -> boolean fs#read

Working-set load: fetch ONE integer-keyed entry from a persisted HASH image into the empty local hash local, reading only the pages the lookup touches — not the whole file. The bounded-fetch counterpart of store_load, for when local should hold only the entries actually asked for (a phone pulling the few map tiles a route needs from a large block). The singular of store_load_keys and the integer form of store_load_key_text. path is a local file or an http(s):// URL served with Range, on every target including the browser (--html), where the fetch goes through the same bridge store_load_url_trusted uses. Returns false when the key is absent, the file is unreadable, or the collection is not an integer-keyed hash.

The entry's own fields are RELOCATED into the local store, so text, nested structs and flat vectors all come across; only a vector<text> or a vector<vector> is refused (its element pointers would dangle), and a refusal says so on stderr rather than looking like an absent key. tiles: hash<Tile[id]> = [] store_load_key(tiles, "block.store", 42) // tiles now holds entry 42 only

pub fn store_load_key_text(local: reference, path: text, key: text) -> boolean fs#read

Text-keyed form of store_load_key: fetch ONE entry from a persisted hash<T[textkey]> or trie<T[textkey]> (a place-name / string-id index) into local, reading only the pages the lookup touches. Returns false when the key is absent or the collection isn't a copyable text-keyed hash or trie. places: hash<Place[name]> = [] store_load_key_text(places, "gazetteer.store", "Amsterdam")

pub fn store_load_prefix(local: reference, path: text, pre: text, limit: integer) -> integer fs#read

Prefix form: fetch every entry whose text key begins with pre from a persisted trie<T[k]> into local, reading only the pages the prefix walk touches — what a search box needs, and what a sorted range cannot express without a hand-built successor string. Returns the count loaded.

limit caps the WALK, not just the answer: with limit 8 the ninth record is never stepped to, so its pages are never fetched. A negative limit means no cap, which on a common prefix reads the whole run. words: trie<Word[w]> = [] store_load_prefix(words, "vocab.store", "kerk", 20)

pub fn store_load_box(local: reference, path: text, from: const vector<integer>, till: const vector<integer>, limit: integer) -> integer fs#read

Box form: fetch every entry inside the closed bounding box from..till from a persisted spatial<T[x, y]> into local, reading only the pages the box walk touches — what a map viewport needs. Returns the count loaded. The corners are vectors so the same call serves 1, 2 or 3 axes, and writing them the other way round names the same box.

TWO bounds, and a map needs both. limit caps the WALK, not just the answer: with limit 200 the 201st marker is never stepped to, so its pages are never fetched (a negative limit means no cap). And the BOX bounds it — the Morton interval between two corners is a superset the Z-order curve threads in and out of, so a wide, shallow viewport would otherwise read 1.46 M records to return 4 k. Measured on a 3.2 M-point map index: 5.3 pages of 64 KB for the first viewport, ~1.5 for each pan after it, against a 158 MB whole-image download.

Those numbers assume a dataset written with locality in every axis, which is the one thing this call cannot do for you. The Morton walk is symmetric; a file laid out along ONE axis is not, so a box crossing that axis pays for every stride it crosses. On a 62 500-point grid returning the same 500 records, a 250x2 box read 107 pages of 64 KiB against 7 for its 2x250 mirror, and the two swapped when the identical data was written in the other axis order — 81 % of the image to return 0.8 % of the records. Write such a dataset TILED: it has no bad orientation, and for the square-ish boxes a viewport uses it beats either linear order. pins: spatial<Pin[x, y]> = [] store_load_box(pins, "map.store", [x1, y1], [x2, y2], 200)

pub fn store_load_keys(local: reference, path: text, keys: const vector<integer>) -> integer fs#read

Plural form of store_load_key: fetch the given integer keys' entries into local in one call (the paged reader is opened once and its cache reused), returning how many were found. Keys absent from the remote are skipped. Same relocation rules as store_load_key. tiles: hash<Tile[id]> = [] got = store_load_keys(tiles, "block.store", [7, 13, 42]) // got == 3

pub fn store_load_keys_text(local: reference, path: text, keys: const vector<text>) -> integer fs#read

Plural form of store_load_key_text, and the text twin of store_load_keys: fetch the given text keys' entries into local in ONE call, returning how many were found. Keys absent from the remote are skipped. Serves a hash<T[k]> and a trie<T[k]> alike, like the single-key form.

Looping store_load_key_text is not the same call: each one opens its own reader, so a ring of twenty asset names re-fetches the same 64 KiB bucket-table page twenty times. This opens the reader once and shares its page cache — which is what makes it the PREFETCH call: ask for the ring at a load or level boundary, so no frame is ever the thing that discovers it needs an asset. art: hash<Blob[bl_key]> = [] got = store_load_keys_text(art, "pack.store", ["page/mobs", "hit.ogg"])

pub fn store_load_range(local: reference, path: text, lo: integer, hi: integer) -> integer fs#read

Range form: fetch every entry whose integer key is in [lo, hi] from a persisted sorted<T[k]> into local, reading only the pages the range walk touches — the ordered-collection counterpart of store_load_keys (a phone pulling the corridor of map tiles a route crosses). Returns the count loaded. tiles: sorted<Tile[tkey]> = [] store_load_range(tiles, "block.store", lo_cell, hi_cell)