From 7d4a2249c2f2715ba6dddcbb98750597b1da5fd6 Mon Sep 17 00:00:00 2001 From: Shahzad Lone Date: Sat, 9 Jul 2022 12:10:28 -0400 Subject: [PATCH] wip: Add implementation of explaining both limit nodes. --- query/graphql/planner/explain.go | 16 ++++++++++------ query/graphql/planner/limit.go | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/query/graphql/planner/explain.go b/query/graphql/planner/explain.go index b3256d4b96..5a418b608f 100644 --- a/query/graphql/planner/explain.go +++ b/query/graphql/planner/explain.go @@ -21,18 +21,20 @@ type explainablePlanNode interface { // Compile time check for all planNodes that should be explainable (satisfy explainablePlanNode). var ( - _ explainablePlanNode = (*createNode)(nil) - _ explainablePlanNode = (*deleteNode)(nil) - _ explainablePlanNode = (*scanNode)(nil) - _ explainablePlanNode = (*selectNode)(nil) - _ explainablePlanNode = (*selectTopNode)(nil) - _ explainablePlanNode = (*typeIndexJoin)(nil) _ explainablePlanNode = (*averageNode)(nil) _ explainablePlanNode = (*commitSelectNode)(nil) _ explainablePlanNode = (*countNode)(nil) + _ explainablePlanNode = (*createNode)(nil) _ explainablePlanNode = (*dagScanNode)(nil) + _ explainablePlanNode = (*deleteNode)(nil) + _ explainablePlanNode = (*hardLimitNode)(nil) _ explainablePlanNode = (*orderNode)(nil) + _ explainablePlanNode = (*renderLimitNode)(nil) + _ explainablePlanNode = (*scanNode)(nil) + _ explainablePlanNode = (*selectNode)(nil) + _ explainablePlanNode = (*selectTopNode)(nil) _ explainablePlanNode = (*sumNode)(nil) + _ explainablePlanNode = (*typeIndexJoin)(nil) _ explainablePlanNode = (*updateNode)(nil) ) @@ -44,6 +46,8 @@ const ( fieldNameLabel = "fieldName" filterLabel = "filter" idsLabel = "ids" + limitLabel = "limit" + offsetLabel = "offset" sourcesLabel = "sources" spansLabel = "spans" ) diff --git a/query/graphql/planner/limit.go b/query/graphql/planner/limit.go index 07600199a7..8eab8610c8 100644 --- a/query/graphql/planner/limit.go +++ b/query/graphql/planner/limit.go @@ -81,6 +81,13 @@ func (n *hardLimitNode) Next() (bool, error) { func (n *hardLimitNode) Source() planNode { return n.plan } +func (n *hardLimitNode) Explain() (map[string]interface{}, error) { + return map[string]interface{}{ + limitLabel: n.limit, + offsetLabel: n.offset, + }, nil +} + // limit the results, flagging any records outside the bounds of limit/offset with // with a 'hidden' flag blocking rendering. Used if consumers of the results require // the full dataset. @@ -139,3 +146,10 @@ func (n *renderLimitNode) Next() (bool, error) { } func (n *renderLimitNode) Source() planNode { return n.plan } + +func (n *renderLimitNode) Explain() (map[string]interface{}, error) { + return map[string]interface{}{ + limitLabel: n.limit, + offsetLabel: n.offset, + }, nil +}