MCPcopy Create free account
hub / github.com/cloudspannerecosystem/spanner-cli / renderTreeWithStats

Function renderTreeWithStats

query_plan.go:240–275  ·  view source on GitHub ↗
(tree treeprint.Tree, linkType string, node *Node)

Source from the content-addressed store, hash-verified

238}
239
240func renderTreeWithStats(tree treeprint.Tree, linkType string, node *Node) {
241 // Scalar operator is rendered if and only if it is linked as Scalar type(Scalar/Array Subquery)
242 if node.PlanNode.GetKind() == pb.PlanNode_SCALAR && linkType != "Scalar" {
243 return
244 }
245
246 b, _ := json.Marshal(
247 QueryPlanNodeWithStats{
248 ID: node.PlanNode.Index,
249 ExecutionStats: node.PlanNode.GetExecutionStats(),
250 DisplayName: node.String(),
251 LinkType: linkType,
252 },
253 )
254 // Prefixed by tab to ease to split
255 str := "\t" + string(b)
256
257 if len(node.Children) > 0 {
258 var branch treeprint.Tree
259 if node.IsRoot() {
260 tree.SetValue(str)
261 branch = tree
262 } else {
263 branch = tree.AddBranch(str)
264 }
265 for _, child := range node.Children {
266 renderTreeWithStats(branch, child.Type, child.Dest)
267 }
268 } else {
269 if node.IsRoot() {
270 tree.SetValue(str)
271 } else {
272 tree.AddNode(str)
273 }
274 }
275}
276
277func getMaxRelationalNodeID(plan *pb.QueryPlan) int32 {
278 var maxRelationalNodeID int32

Callers 1

RenderTreeWithStatsMethod · 0.85

Calls 2

IsRootMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected