Skip to content

Commit

Permalink
wip: Add implementation for explaining dagscanNode attribute(s) + Fix
Browse files Browse the repository at this point in the history
the test post rebasing of doc restructure changes.
  • Loading branch information
shahzadlone committed Jul 6, 2022
1 parent e31b4d6 commit e7a45b8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
24 changes: 18 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,23 @@ 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{}{}
if 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
18 changes: 8 additions & 10 deletions tests/integration/query/explain/dagscan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ func TestExplainAllCommitsDagScan(t *testing.T) {
{
"explain": dataMap{
"selectTopNode": dataMap{
"renderNode": dataMap{
"selectNode": dataMap{
"filter": nil,
"commitSelectNode": dataMap{
"dagScanNode": dataMap{
"spans": []dataMap{
{
"start": "/test-key/1",
"end": "/test-key/2",
},
"selectNode": dataMap{
"filter": nil,
"commitSelectNode": dataMap{
"dagScanNode": dataMap{
"spans": []dataMap{
{
"start": "/test-key/1",
"end": "/test-key/2",
},
},
},
Expand Down

0 comments on commit e7a45b8

Please sign in to comment.