Skip to content

Commit

Permalink
wip: Fix sourcenetwork#486, wrapped scanNode bug by making multiscanN…
Browse files Browse the repository at this point in the history
…ode adhere to

plan node and be non-explainable.
  • Loading branch information
shahzadlone committed May 31, 2022
1 parent cc4b5df commit d940f7b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
1 change: 1 addition & 0 deletions query/graphql/planner/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var (
_ planNode = (*groupNode)(nil)
_ planNode = (*hardLimitNode)(nil)
_ planNode = (*headsetScanNode)(nil)
_ planNode = (*multiScanNode)(nil)
_ planNode = (*parallelNode)(nil)
_ planNode = (*pipeNode)(nil)
_ planNode = (*renderLimitNode)(nil)
Expand Down
34 changes: 29 additions & 5 deletions query/graphql/planner/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,20 @@ func (p *Planner) Scan(versioned bool) *scanNode {
// we call Next() on the underlying scanNode only
// once every 2 Next() calls on the multiScan
type multiScanNode struct {
*scanNode
scanNode *scanNode
numReaders int
numCalls int

lastBool bool
lastErr error
}

func (n *multiScanNode) addReader() {
n.numReaders++
func (n *multiScanNode) Init() error {
return n.scanNode.Init()
}

func (n *multiScanNode) Source() planNode {
return n.scanNode
func (n *multiScanNode) Start() error {
return n.scanNode.Start()
}

// Next only calls Next() on the underlying
Expand All @@ -190,3 +190,27 @@ func (n *multiScanNode) Next() (bool, error) {

return n.lastBool, n.lastErr
}

func (n *multiScanNode) Value() map[string]interface{} {
return n.scanNode.documentIterator.Value()
}

func (n *multiScanNode) Spans(spans core.Spans) {
n.scanNode.Spans(spans)
}

func (n *multiScanNode) Source() planNode {
return n.scanNode
}

func (n *multiScanNode) Kind() string {
return "multiScanNode"
}

func (n *multiScanNode) Close() error {
return n.scanNode.Close()
}

func (n *multiScanNode) addReader() {
n.numReaders++
}
10 changes: 0 additions & 10 deletions tests/integration/query/explain/with_count_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,6 @@ func TestExplainQueryOneToManyMultipleWithCounts(t *testing.T) {
"collectionID": "3",
"collectionName": "author",
"filter": nil,
"scanNode": dataMap{
"collectionID": "3",
"collectionName": "author",
"filter": nil,
},
},
},
},
Expand All @@ -200,11 +195,6 @@ func TestExplainQueryOneToManyMultipleWithCounts(t *testing.T) {
"collectionID": "3",
"collectionName": "author",
"filter": nil,
"scanNode": dataMap{
"collectionID": "3",
"collectionName": "author",
"filter": nil,
},
},
},
},
Expand Down

0 comments on commit d940f7b

Please sign in to comment.