Collections: One Lookup, Three Layouts

What the viewer will understand

How does the same lookup reach the value in a Nyxus Map, a Hylix Map, and a Minima FrozenHashMap? After the three engine films, the viewer can follow a search through each representation and explain what an edit requires in each case. Aim for three to four minutes. The final shot leaves the value stored, ready for the question of what a code upgrade can reopen.

The worked example

Use the separate benches/minima fixture. It seeds 100,000 entries under equivalent keys across the three maps. tables.Data holds the Nyxus native map and the Minima hash descriptor. Its baseline child holds the Hylix map. The first measured sample uses index 7936. With key(i) = 2 * i + 2, the count-one hit asks for 15874 and the miss pattern asks for 15875. Each hit returns the same value, 0xd6e8_feb8_5859_fd93. Each miss returns None from the collection. In the outer benchmark result the hit increments found and contributes its value to checksum. The miss contributes zero to both. Show the inner lookup results. Input and result model · Lookup dispatch and population · Tables Data and child declaration · Hylix declaration

The sample's replacement value is 0xd7cb_bbdf_d1f2_307c. The benchmark edits the two B-tree maps via insert in separate series, restoring the original values afterward. Its frozen map keeps the original value. Show that result before a separate illustration in which an owner builds a replacement from the full revised input with FrozenHashMap::build. The Hylix storyboard uses get_mut on the same scalar to show a decoded edit guard writing back to the slot. The B-tree node arrangements are schematic. Runner and mutation oracle · Benchmark replacement · Hylix benchmark methods · Hylix edit guard · Frozen map build and lookup

Recomputing FrozenHashMap placement for the benchmark's 100,000 keys and default configuration gives 448 buckets at the first successful seed. Key 15874 is in primary bucket 276, slot 21. Key 15875 misses in bucket 440 and its backup 232. These are logical positions derived from the build algorithm. Physical stable addresses and provider timings need a trace. Benchmark build input · Placement algorithm

The story in one pass

Send a hit and a miss through three maps. Nyxus follows native B-tree links. Hylix follows stable block identities and decodes the value. Minima probes buckets in borrowed workspace. Then replace a value in the two mutable maps and read the original from the frozen map. An illustrated rebuild shows how an owner can replace that index.

Components and views

  • Draw the benchmark fixture's own actor root, its tables child, and tables's baseline child using the established module geometry. Frame the lookup paths so the unrelated sketches branch stays outside the close-ups. Keep the native map and frozen descriptor inside tables.Data and Hylix's map inside baseline.Data. Fixture's root wiring · Shared visual language
  • Reuse the MemoryMapNode frame at each zoom. Use native child pointers for Nyxus and Block links with offset and generation for Hylix. The Hylix nodes sit in its virtual stable image from lesson five. Bring their encoded bytes into the WorkingSet before showing the ordered-key comparison. The illustrated fields show the search sequence. A byte-layout close-up of Hylix places keys, values and children in their separate packed regions. Hylix layout and search
  • Use the Minima lesson's physical block, 4 KiB position, and workspace tray for the frozen hash map. A bucket occupies one node position. At the close-up, show its entry count, fixed key area, and fixed value area in that order. lookup(15874) and lookup(15875) are diagram labels for the inner map requests.
  • fixture_tree shows the participant modules and their representations in main memory and stable memory. native_search and stable_search frame the B-tree routes, with the WorkingSet visible for the Hylix search. bucket_probe frames a selected bucket and the borrowed tray. replace_view returns to the representation being edited, with its owned entry or index descriptor in view.

Scene collections_set_up — Give three maps the same key

Enters with Cut from the Minima probe to the benchmark canister while carrying the waiting 15874 key at the same position on screen. The three maps have already been populated.

Beat collections_maps — Find the three collection fields

View and focus In fixture_tree, follow tables.Data to the Nyxus map and Minima descriptor, then trace the attached baseline child to its Hylix map.

Narration

This benchmark canister puts the same hundred thousand entries in three maps. Tables holds a native Nyxus map and a Minima frozen hash descriptor. Its baseline child holds the Hylix map.

Cue and animation On “Tables holds” reveal the two fields inside tables.Data. On “Its baseline child” trace the existing attachment to the Hylix owner. Keep storage paths below the tree.

Leaves with Three map fields and their storage paths are readable at the starting view.

Beat collections_keys — Prepare one hit and one miss

View and focus Frame the request path in the foreground, with the map owners behind it and the native path in view.

Narration

Every stored key is even. We'll look up fifteen thousand eight hundred and seventy-four, then the odd key that follows it. The first key has a value. The second is absent.

Cue and animation On “look up fifteen thousand” send the waiting key as lookup(15874). On “then the odd key” prepare lookup(15875) to follow the first result.

Leaves with 15874 at the Nyxus tree and 15875 waiting its turn.

Scene collections_btrees — Follow the two ordered trees

Enters with The first request at the native map. Both storage representations are rooted in the fixture drawing.

Beat collections_native_lookup — Compare keys in Nyxus

View and focus Zoom to native_search. Place the search key beside the active node's ordered keys.

Narration

Nyxus compares the key with entries in native B-tree nodes. Each comparison can settle the search or tell it which child to follow. The even key finds its value in the tree. The odd key runs out of places to look.

Cue and animation On “compares the key” follow the ordered child path. At “finds its value” lift the stored value chip from the selected native row. At “runs out of places” finish the second path on a missing match and return None.

Leaves with Both native results have arrived, and the selected value is still visible inside its node.

Beat collections_hylix_lookup — Follow stable offsets

View and focus Return briefly along the owner path and pan to stable_search beneath baseline. Use the same two key requests.

Narration

Hylix also searches ordered keys. Its child links name blocks in its virtual stable image. It reads their bytes through the working set. The even key finds a value to decode. The odd key comes back empty.

Cue and animation On “child links name blocks” follow a Block link into the virtual image. On “through the working set” emphasize the node bytes being searched there. On “finds a value to decode” lift the decoded value from the matched entry. On “The odd key comes back empty” finish the second search and return None.

Leaves with The Hylix results agree with the native results. The view can follow the owner path to the frozen descriptor.

Scene collections_hash — Probe Minima's buckets

Enters with Both B-tree results visible at their outputs. The single physical stable band also contains the frozen map's blocks.

Beat collections_hash_hit — Check the primary bucket

View and focus Move to bucket_probe. Keep the selected stable bucket and the caller's Minima workspace side by side.

Narration

The frozen hash map hashes the key to choose a primary bucket. It reads the whole four-kibibyte bucket into borrowed workspace. This bucket holds our even key. The map decodes the matching value and returns it.

Cue and animation On “choose a primary bucket” follow 15874 to logical bucket 276. On “reads the whole” fill the workspace with that node. On “holds our even key” select its matching entry and return the decoded value. Leave the other bucket and physical placement off this close-up.

Leaves with The hit value has returned and the workspace can be borrowed again.

Beat collections_hash_miss — Check the backup bucket

View and focus Keep bucket_probe framing and send the absent odd key to the primary position.

Narration

The absent key fails the exact comparison in its primary bucket. The map tries a backup bucket, using the same workspace. The second check also misses, so the lookup returns none.

Cue and animation On “fails the exact comparison” finish the probe of logical bucket 440. On “tries a backup bucket” refill the same tray from logical bucket 232. Return None on “returns none.”

Leaves with All three maps have agreed on the hit and miss. The key 15874 is ready to be used for a replacement.

Scene collections_edit — Change the value

Enters with All three representations populated with the original value. The replacement uses the same key and a value drawn from the benchmark model.

Beat collections_native_edit — Replace a native entry

View and focus Use replace_view on the same selected Nyxus row. Keep its key readable.

Narration

Give the Nyxus map a replacement for the even key. The native map writes the new Rust value into the existing entry.

Cue and animation On “writes the new Rust value” send the replacement to the selected row, with 0xd7cb_bbdf_d1f2_307c arriving at the same key.

Leaves with The replacement is visible in the native row and the key can travel toward Hylix.

Beat collections_hylix_edit — Close a decoded edit guard

View and focus Use replace_view at the same Hylix entry and include the decoded edit guard and working set.

Narration

Hylix can edit through a guard. It decodes the value for this write frame. When the guard drops, it encodes the replacement back into the original slot. The frame then flushes the changed bytes.

Cue and animation On “decodes the value” show the get_mut(15874) example lifting the value into an Edit tile. On “When the guard drops” fold the tile away and encode the replacement into its slot in the working set. On “flushes the changed bytes” send the span to stable memory. The shot keeps this segment resident until frame completion.

Leaves with The replacement is stored at the selected Hylix key, and the temporary guard has closed.

Scene collections_frozen_update — Replace a frozen index

Enters with The two mutable-map edit examples complete. The frozen index still holds the original entries.

Beat collections_frozen_original — Read the old value

View and focus Return to bucket_probe with the existing index still owned by tables.Data.hash.

Narration

Look up the same key in the benchmark's frozen map. It still returns the original value. The benchmark builds this index once from the starting entries.

Cue and animation On “in the benchmark's frozen map” send lookup(15874) into the current index. On “still returns the original value” show 0xd6e8_feb8_5859_fd93 coming back along the original route.

Leaves with The viewer has seen why an edit to the mutable maps leaves the frozen map's answer alone.

Beat collections_frozen_rebuild — Build a replacement frozen index

View and focus Use replace_view at the Minima descriptor and keep the original bucket in sight below it.

Narration

To revise a frozen map, build a new index from the full entry list with that one value changed. Once the build succeeds, the owner replaces the old index. The next lookup returns the revised value.

Cue and animation Mark this shot Rebuild example. On “from the full entry list” frame the revised row inside the build input, with the surrounding entries continuing out of frame. Build in separate stable blocks. With the same keys and configuration the logical bucket positions repeat. On “the owner replaces the old index” switch the hash field to the new descriptor and retire the old collection's blocks. On “The next lookup” follow the new route and return the revised value.

Leaves with The illustrative replacement is attached to the same owner and answers for the revised entry.

Beat collections_handoff — Point back to main memory

View and focus Widen to fixture_tree, with the main-memory strip and both rooted paths below it.

Narration

The native tree and the retained descriptors sit in main memory. The Hylix nodes and the frozen buckets sit in stable memory. What happens to the retained heap when the canister installs new code?

Cue and animation On “sit in main memory” trace the Nyxus nodes and the Minima and Hylix retained descriptors. On “sit in stable memory” trace the Hylix node and Minima bucket routes. On “installs new code” hold on the main-memory strip for the cut to the populated KEEP fixture.

Leaves with The retained heap in view and the storage changes complete.

Review notes

  • Check the common hit and miss through kinds 8, 5, and 3 at the first sample index. Compare the one-entry result to the runner oracle and use the collection's None for the inner miss. Benchmark oracle and input sequence
  • Scrub the native and Hylix scenes muted. The viewer should be able to follow a key, distinguish native pointers from stable offsets, and locate the returned value. Use schematic nodes, unnumbered routes, and editorial pacing for both trees.
  • Confirm Minima fills workspace once per bucket probe, checks the exact key and tries the backup on a primary miss. The positions given above reproduce the first successful default placement over the benchmark's even keys. FrozenHashMap::find_slot and placement
  • Review the Hylix guard-drop and physical writeback as separate cues. The benchmark's existing-key insert writes the selected value slot directly. The guard demonstration shows the same storage effect through get_mut. The frozen-map rebuild and owner swap are a separate teaching example. The runner's mutation series restore the originals before their next series. Hylix map writes · Mutation series

Previous lesson · Minima · Next lesson · KEEP