Documentation
¶
Index ¶
- func BuildGraph(plan *Plan, opts GraphOptions) (*graphmodel.Graph, error)
- func FormatQueryNode(queryStats map[string]*structpb.Value, showQueryStats bool) string
- func RenderGraphvizNodeHTML(l graphmodel.Label, fallbackID string) string
- func RenderMermaidLabel(l graphmodel.Label, fallback string) string
- func RenderQueryNodeHTML(q *graphmodel.QueryText) string
- type BuildOptions
- type EdgeStyle
- type GraphOptions
- type Link
- type Plan
- type Renderer
- type RendererFunc
- type TreeNode
- func (n *TreeNode) GetExecutionSummary(param BuildOptions) string
- func (n *TreeNode) GetMetadata(param BuildOptions) map[string]string
- func (n *TreeNode) GetName() string
- func (n *TreeNode) GetNonVarScalarLinksOutput() string
- func (n *TreeNode) GetScanInfoOutput(param BuildOptions) string
- func (n *TreeNode) GetSerializeResultOutput(rowType *sppb.StructType) string
- func (n *TreeNode) GetShortRepresentation() string
- func (n *TreeNode) GetStats(param BuildOptions) map[string]string
- func (n *TreeNode) GetTitle() string
- func (n *TreeNode) GetTooltip() (string, error)
- func (n *TreeNode) GetVarScalarLinksOutput() string
- func (n *TreeNode) HTML(param BuildOptions, rowType *sppb.StructType) string
- func (n *TreeNode) MermaidLabel(param BuildOptions, rowType *sppb.StructType) string
- func (n *TreeNode) Metadata(param BuildOptions, rowType *sppb.StructType) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildGraph ¶ added in v0.10.1
func BuildGraph(plan *Plan, opts GraphOptions) (*graphmodel.Graph, error)
BuildGraph resolves a built Plan into the backend-neutral graphmodel.Graph: node labels (via buildNodeLabel using plan.Build), tooltips (canonical YAML), edge styles, and the optional query-text node. Serializers consume the graph instead of walking the TreeNode graph directly.
Node identity from the TreeNode graph is preserved: a TreeNode reached from multiple parents maps to a single *graphmodel.Node, so pointer sharing in the source survives into the model. Each serializer keeps its own traversal order (the dot path emits a full pre-order traversal; the mermaid path dedups by node ID), so the resolved model does not move any bytes.
Labels are built with plan.Build. Callers that need to override build options at render time (for example mermaid.SourceWithOptions) do so by shallow-copying the Plan and setting Plan.Build before calling BuildGraph.
func FormatQueryNode ¶ added in v0.9.0
FormatQueryNode renders the Graphviz HTML-like query node label directly from a ResultSetStats query_stats map. It is retained for backward compatibility and now delegates to the structured buildQueryText/RenderQueryNodeHTML path so there is a single source of truth for the query node content.
func RenderGraphvizNodeHTML ¶ added in v0.10.1
func RenderGraphvizNodeHTML(l graphmodel.Label, fallbackID string) string
RenderGraphvizNodeHTML renders a graphmodel.Label as the full Graphviz HTML-like node label (title composed with the body/stats fragment). fallbackID is emitted (HTML-escaped) when the label is empty. It is exported so the dot serializer can render the graph IR built by BuildGraph.
func RenderMermaidLabel ¶ added in v0.10.1
func RenderMermaidLabel(l graphmodel.Label, fallback string) string
RenderMermaidLabel renders a graphmodel.Label as a Mermaid flowchart HTML-ish label. fallback is used verbatim (after escaping) when the label would otherwise be empty. It is exported so the mermaid serializer can render the graph IR built by BuildGraph.
func RenderQueryNodeHTML ¶ added in v0.10.1
func RenderQueryNodeHTML(q *graphmodel.QueryText) string
RenderQueryNodeHTML renders a graphmodel.QueryText as the Graphviz HTML-like query node label: the query text in bold, followed by the italic stat lines when present. It is exported so the dot serializer can render the query node from the graph IR built by BuildGraph.
Types ¶
type BuildOptions ¶ added in v0.9.0
type BuildOptions struct {
Full bool
NonVariableScalar bool
VariableScalar bool
Metadata bool
ExecutionStats bool
ExecutionSummary bool
SerializeResult bool
HideScanTarget bool
HideMetadata []string
}
BuildOptions controls which plan details are included when building a diagram model.
func FullBuildOptions ¶ added in v0.9.0
func FullBuildOptions() BuildOptions
FullBuildOptions returns settings equivalent to CLI --full.
func StructureBuildOptions ¶ added in v0.9.0
func StructureBuildOptions() BuildOptions
StructureBuildOptions returns operator structure suitable for interactive viewers without execution stats-heavy output.
func (*BuildOptions) ApplyFull ¶ added in v0.9.0
func (o *BuildOptions) ApplyFull()
ApplyFull enables all detail flags used by the CLI --full preset.
type EdgeStyle ¶ added in v0.9.0
type EdgeStyle int
EdgeStyle describes how an edge between plan nodes should be drawn.
type GraphOptions ¶ added in v0.10.1
type GraphOptions struct {
// ShowQuery adds a query-text node built from the ResultSetStats query_stats.
ShowQuery bool
// ShowQueryStats adds the query statistics to the query-text node.
ShowQueryStats bool
}
GraphOptions controls optional content included when building the backend-neutral graph model.
type Plan ¶ added in v0.9.0
type Plan struct {
Root *TreeNode
QueryPlan *spannerplan.QueryPlan
RowType *sppb.StructType
QueryStats *sppb.ResultSetStats
Build BuildOptions
}
Plan is a built diagram model ready for backend renderers.
func BuildPlan ¶ added in v0.9.0
func BuildPlan(rowType *sppb.StructType, queryStats *sppb.ResultSetStats, opts BuildOptions) (*Plan, error)
BuildPlan constructs a diagram model from query plan stats.
type RendererFunc ¶ added in v0.9.0
RendererFunc adapts a function to Renderer.
type TreeNode ¶ added in v0.9.0
type TreeNode struct {
// Essential fields for graph structure
Children []*Link
// contains filtered or unexported fields
}
func (*TreeNode) GetExecutionSummary ¶ added in v0.9.0
func (n *TreeNode) GetExecutionSummary(param BuildOptions) string
func (*TreeNode) GetMetadata ¶ added in v0.9.0
func (n *TreeNode) GetMetadata(param BuildOptions) map[string]string
func (*TreeNode) GetName ¶ added in v0.9.0
GetName generates the node's unique ID for graph rendering.
func (*TreeNode) GetNonVarScalarLinksOutput ¶ added in v0.9.0
func (*TreeNode) GetScanInfoOutput ¶ added in v0.9.0
func (n *TreeNode) GetScanInfoOutput(param BuildOptions) string
func (*TreeNode) GetSerializeResultOutput ¶ added in v0.9.0
func (n *TreeNode) GetSerializeResultOutput(rowType *sppb.StructType) string
func (*TreeNode) GetShortRepresentation ¶ added in v0.9.0
func (*TreeNode) GetStats ¶ added in v0.9.0
func (n *TreeNode) GetStats(param BuildOptions) map[string]string
func (*TreeNode) GetTooltip ¶ added in v0.9.0
GetTooltip generates the tooltip string on demand. The tooltip is the canonical protojson-over-YAML rendering of the plan node (proto field names in camelCase, named enums, and field-number ordering).
func (*TreeNode) GetVarScalarLinksOutput ¶ added in v0.9.0
func (*TreeNode) HTML ¶ added in v0.9.0
func (n *TreeNode) HTML(param BuildOptions, rowType *sppb.StructType) string
func (*TreeNode) MermaidLabel ¶ added in v0.9.0
func (n *TreeNode) MermaidLabel(param BuildOptions, rowType *sppb.StructType) string
MermaidLabel generates the label string for this node, suitable for use in Mermaid diagrams.
func (*TreeNode) Metadata ¶ added in v0.9.0
func (n *TreeNode) Metadata(param BuildOptions, rowType *sppb.StructType) string
Metadata formats node content for GraphViz HTML-like labels.