Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add ability to explain dagScanNode attribute(s). #560

Merged
merged 3 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading