queryopt

package
v1.50.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StandardOptimzations = []string{
	"simple-caveat-pushdown",
	"reachability-pruning",
}

StandardOptimzations is the default set of optimization names applied when no custom selection is required.

Functions

func ApplyOptimizations

func ApplyOptimizations(co query.CanonicalOutline, names []string, requestParams RequestParams) (query.CanonicalOutline, error)

ApplyOptimizations looks up each optimizer by name, sorts them by descending Priority (higher priority runs first), and applies their mutations to the outline via query.MutateOutline. Nodes that survive mutation unchanged keep their existing IDs. Newly synthesized nodes (ID==0) receive fresh IDs via query.FillMissingNodeIDs. The returned CanonicalOutline is ready to compile.

func MustRegisterOptimization

func MustRegisterOptimization(opt Optimizer)

Types

type Optimizer

type Optimizer struct {
	Name        string
	Description string
	// NewTransform creates a whole-tree transformation for this optimizer,
	// optionally using request-specific parameters. Each transform typically
	// calls query.MutateOutline internally with its own mutations.
	NewTransform func(RequestParams) OutlineTransform
	// Priority controls the order in which optimizations are applied.
	// Higher values run first.
	Priority int
}

Optimizer describes a single named outline optimization.

func GetOptimization

func GetOptimization(name string) (Optimizer, error)

type OutlineTransform

type OutlineTransform func(query.Outline) query.Outline

OutlineTransform is a function that transforms an entire outline tree. Each optimizer produces one of these, and they are applied sequentially.

type RequestParams

type RequestParams struct {
	SubjectType     string
	SubjectRelation string
}

RequestParams holds request-specific values available to optimizations. Static (schema-level) optimizations ignore these; request-parameterized optimizations (e.g. reachability pruning) use them to tailor their behavior.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL