Documentation
¶
Overview ¶
Package shape computes and enumerates the reachable query shapes of a template: guard bitmask × one ordinal per @choose block. See docs/design/03-structural-rules.md §9.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Count ¶
func Count(q *template.QueryTemplate) *big.Int
Count returns the exact number of reachable shapes (PostgreSQL view: @in contributes no dimension).
func CountExpand ¶
func CountExpand(q *template.QueryTemplate, expandIn bool) *big.Int
CountExpand counts shapes; with expandIn each @in contributes the two representative arities (non-empty, empty). The true runtime arity space is unbounded — verification quotients it to these two classes because IN-list growth is parse-invariant.
Types ¶
type Key ¶
type Key struct {
Guards uint64
Choices []uint8 // one per @choose block, document order
Orders [][]uint8 // one per @order-by block: key<<1|desc sequence
// Ins holds one representative arity per @in construct on
// expanding dialects: 1 stands for every non-empty list (adding an
// element to an IN list is parse-invariant), 0 is the distinct
// empty-list rendering. Empty on PostgreSQL.
Ins []uint8
}
Key identifies one concrete shape.
func Enumerate ¶
func Enumerate(q *template.QueryTemplate, capN int) (keys []Key, truncated bool)
Enumerate yields every shape key in a deterministic order, stopping after cap keys. truncated reports whether the cap cut enumeration short. cap <= 0 means no cap. @order-by blocks contribute their full selection space (empty, every ordered subset, every direction mix). @in contributes no dimension (the PostgreSQL view); expanding dialects use EnumerateExpand.
func EnumerateExpand ¶
func EnumerateExpand(q *template.QueryTemplate, capN int, expandIn bool) (keys []Key, truncated bool)
EnumerateExpand is Enumerate with an optional @in dimension: with expandIn each @in contributes its two representative arities (1 = any non-empty list, 0 = the empty-list rendering).
func (Key) InSelection ¶
func (k Key) InSelection() ast.InSelection
InSelection converts the key's @in arities into the renderer's form.
func (Key) OrderSelection ¶
func (k Key) OrderSelection() ast.OrderSelection
OrderSelection converts the key's order sequences into the renderer's form.
func (Key) Selection ¶
func (k Key) Selection() ast.CaseSelection
Selection converts the key's choices into the renderer's form.