Expand description
A read item: one tensor, or a composite and everything under it.
hurray-io hands a driver a sum type — StreamItem and FileItem are each a tensor
or a composite whose members are items in turn — and C has no sum type to receive it
in. This module is the answer ADR-041 § Open Questions asked for: an item crosses as
the sequence the format itself uses, a head followed by its members, with each
node declaring how many of the nodes after it are its own
(ADR-027 § Binding).
So walking a composite from C is a loop over an array, and the nesting is in the
member_count column:
index kind name member_count
0 composite "w" 2 <- the head, nodes[0]
1 tensor "w.0" 0
2 composite "w.1" 2 <- a nested head: its members follow it
3 tensor "w.1.0" 0
4 tensor "w.1.1" 0Preorder rather than a tree of pointers, for a reason that outlives taste: a pointer tree crossing an ABI can be cyclic, and a walker on either side loops forever on one. An array with member counts cannot describe a cycle at all — every child sits after its parent.
Both surfaces produce this: hurray_reader_next_item
from the stream core’s assembler, and
hurray_file_reader_read_composite from
the file core’s walk. A composite is the same shape whichever one carried it.
Structs§
- Hurray
Item - Opaque handle to one read item: a tensor, or a composite and its whole subtree.
- Hurray
Item Node - One node of an item, as a C caller sees it.
Constants§
- HURRAY_
ITEM_ COMPOSITE - A composite head: it owns no buffers, and the next
member_countsibling-level nodes are its members. - HURRAY_
ITEM_ TENSOR - A plain tensor: it owns buffers and no node after it belongs to it.
Functions§
- hurray_
item_ ⚠destroy - Destroys an item, every tensor and name it owns, then writes null through
handle. - hurray_
item_ ⚠kind - The item’s own kind:
HURRAY_ITEM_TENSORorHURRAY_ITEM_COMPOSITE. - hurray_
item_ ⚠node - Copies node
indexintoout_node. - hurray_
item_ ⚠node_ count - How many nodes the item has in total, counting the root and every nested member.