Skip to content

Commit

Permalink
wip: Add implementation for explaining dagscanNode attribute(s).
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzadlone committed Jul 6, 2022
1 parent 37c4749 commit 00a91d3
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions query/graphql/planner/dagscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,6 @@ type dagScanNode struct {

headset *headsetScanNode
parsed *mapper.CommitSelect

// previousScanNode planNode
// linksScanNode planNode

// block blocks.Block
}

func (p *Planner) DAGScan(parsed *mapper.CommitSelect) *dagScanNode {
Expand All @@ -178,6 +173,7 @@ func (n *dagScanNode) Init() error {
}
return nil
}

func (n *dagScanNode) Start() error {
if n.headset != nil {
return n.headset.Start()
Expand Down Expand Up @@ -230,7 +226,24 @@ func (n *dagScanNode) Source() planNode { return n.headset }
// Explain method returns a map containing all attributes of this node that
// are to be explained, subscribes / opts-in this node to be an explainablePlanNode.
func (n *dagScanNode) Explain() (map[string]interface{}, error) {
return map[string]interface{}{}, nil
// explain the spans attribute.
spansExplainer := []map[string]interface{}{}
// Note: n.headset is `nil` for single commit selection query, so must check for it.
if n.headset != nil && n.headset.spans.HasValue {
for _, span := range n.headset.spans.Value {
spansExplainer = append(
spansExplainer,
map[string]interface{}{
"start": span.Start().ToString(),
"end": span.End().ToString(),
},
)
}
}

return map[string]interface{}{
spansLabel: spansExplainer,
}, nil
}

func (n *dagScanNode) Next() (bool, error) {
Expand Down

0 comments on commit 00a91d3

Please sign in to comment.