External-memory node-access oracle model for classic B-trees #
Read-only classic B-tree queries in an external-memory / page-read oracle model built on
PFunctor.FreeM. A tree is never passed as an inductive BTree α β value to a query program:
instead, a reference is Option H over an abstract handle type H, where none represents an
empty leaf without issuing a page read and some h can be inspected only by issuing a readNode h
query against a stateless Store α β H oracle.
Counting is structural via PFunctor.FreeM.countQueries: no program parametric in H can inspect
a node's keys or child handles without paying 1 query per node read. For order-statistic rankR
queries, which skip subtrees in O(height) page reads without reading skipped child pages,
RankedNodeView augments each child reference in a page with its subtree entry count
(RankedStore, DenotesRanked), paired with a forgetful projection RankedStore.toStore to the
unaugmented store.
Main definitions #
NodeAccess.PageEntry,NodeAccess.NodeView,NodeAccess.nodeQuery,NodeAccess.NodeM,NodeAccess.Store,NodeAccess.readNode: unaugmented B-tree page entry, page view, polynomial query functor, program monad, store oracle, and single-page read operation.NodeAccess.Denotes,NodeAccess.DenotesRest: coupling relation asserting that anOption Hreference in aStorerepresents a pureBTree α β.NodeAccess.toRef,NodeAccess.canonicalStore: canonical handle realization witnessing that everyBTree α βadmits a faithfulStore.NodeAccess.RankedChild,NodeAccess.RankedPageEntry,NodeAccess.RankedNodeView,NodeAccess.rankedNodeQuery,NodeAccess.RankedNodeM,NodeAccess.RankedStore,NodeAccess.readRankedNode,NodeAccess.DenotesRanked,NodeAccess.DenotesRankedRest,NodeAccess.canonicalRankedStore: subtree-size-augmented page model forO(height)external-memory rank queries.
Main results #
NodeAccess.eval_readNode,NodeAccess.countQueries_readNode,NodeAccess.eval_readRankedNode,NodeAccess.countQueries_readRankedNode: single-page read evaluation and unit query cost.NodeAccess.denotes_canonicalStore,NodeAccess.denotesRanked_canonicalRankedStore: everyBTree α βis denoted by its canonical handle reference.NodeAccess.DenotesRanked.toDenotes: forgetting child-size annotations preservesDenotes.
References #
Polynomial query signature reading one node page by its handle h : H.
Read-only external-memory computation over nodeQuery α β H.
Stateless page store mapping each handle to its NodeView.
Issue one page-read query for handle h : H.
Canonical page store mapping each BTree α β handle to its top-level children and keys.
Every BTree α β is denoted in canonicalStore by toRef tr.
Entry in an order-statistic B-tree node page: separator key, associated val, and following
RankedChild slot.
- key : α
Separator key.
- val : β
Associated value.
- child : RankedChild H
Following child reference and its subtree entry count.
Instances For
Contents of one order-statistic B-tree node page: first RankedChild and rest
RankedPageEntry records.
- first : RankedChild H
First child reference and its subtree entry count.
- rest : List (RankedPageEntry α β H)
Ordered
(key, val, child)entries of the order-statistic page.
Instances For
Polynomial query signature reading one order-statistic B-tree node page by handle h : H.
Read-only external-memory computation over rankedNodeQuery α β H.
Stateless store mapping each handle to an order-statistic RankedNodeView.
Issue one page-read query for handle h : H in an order-statistic store.
Forget subtree-size annotations to view a RankedStore as an unaugmented Store.
DenotesRanked s ref tr holds when optional handle ref in RankedStore s represents tr
with exact child subtree sizes recorded at every child slot.
Entry-by-entry denotation of an order-statistic node page's RankedPageEntry list.
Forgetting subtree-size annotations preserves tree denotation.
Canonical order-statistic store over H := BTree α β.
Every BTree α β is denoted in canonicalRankedStore by toRef tr.