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

Fix handling of depth parameter for shortest path query. #4347

Merged
merged 18 commits into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
35 changes: 35 additions & 0 deletions query/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,17 @@ func populateCluster() {
<11003> <name> "No. 5 the film"@en .
<11100> <name> "expand" .

<51> <name> "A" .
<52> <name> "B" .
<53> <name> "C" .
<54> <name> "D" .
<55> <name> "E" .
<56> <name> "F" .
<57> <name> "G" .
<58> <name> "H" .
<59> <name> "I" .
<60> <name> "J" .

<1> <full_name> "Michonne's large name for hashing" .

<1> <noindex_name> "Michonne's name not indexed" .
Expand Down Expand Up @@ -610,6 +621,30 @@ func populateCluster() {
<502> <boss> <510> .
<510> <newfriend> <511> .
<510> <newfriend> <512> .

<51> <connects> <52> (weight=10) .
<51> <connects> <53> (weight=1) .
<51> <connects> <54> (weight=10) .

<53> <connects> <51> (weight=10) .
<53> <connects> <52> (weight=10) .
<53> <connects> <54> (weight=1) .

<52> <connects> <51> (weight=10) .
<52> <connects> <53> (weight=10) .
<52> <connects> <54> (weight=10) .

<54> <connects> <51> (weight=10) .
<54> <connects> <52> (weight=1) .
<54> <connects> <53> (weight=10) .
<54> <connects> <55> (weight=1) .


# tests for testing hop behavior for shortest path queries
<56> <connects> <57> (weight=1) .
<56> <connects> <58> (weight=1) .
<58> <connects> <59> (weight=1) .
<59> <connects> <60> (weight=1) .
`)

addGeoPointToCluster(1, "loc", []float64{1.1, 2.0})
Expand Down
4 changes: 2 additions & 2 deletions query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ type params struct {

// ExploreDepth is used by recurse and shortest path queries to specify the maximum graph
// depth to explore.
ExploreDepth uint64
ExploreDepth *uint64

// IsInternal determines if processTask has to be called or not.
IsInternal bool
Expand Down Expand Up @@ -627,7 +627,7 @@ func (args *params) fill(gq *gql.GraphQuery) error {
if err != nil {
return err
}
args.ExploreDepth = depth
args.ExploreDepth = &depth
}

if v, ok := gq.Args["numpaths"]; ok {
Expand Down
6 changes: 3 additions & 3 deletions query/query0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ func TestQueryCountEmptyNames(t *testing.T) {
{in: `{q(func: has(name)) @filter(eq(name, "")) {count(uid)}}`,
out: `{"data":{"q": [{"count":2}]}}`},
{in: `{q(func: has(name)) @filter(gt(name, "")) {count(uid)}}`,
out: `{"data":{"q": [{"count":47}]}}`},
out: `{"data":{"q": [{"count":57}]}}`},
{in: `{q(func: has(name)) @filter(ge(name, "")) {count(uid)}}`,
out: `{"data":{"q": [{"count":49}]}}`},
out: `{"data":{"q": [{"count":59}]}}`},
{in: `{q(func: has(name)) @filter(lt(name, "")) {count(uid)}}`,
out: `{"data":{"q": [{"count":0}]}}`},
{in: `{q(func: has(name)) @filter(le(name, "")) {count(uid)}}`,
Expand All @@ -166,7 +166,7 @@ func TestQueryCountEmptyNames(t *testing.T) {
out: `{"data":{"q": [{"count":2}]}}`},
// NOTE: match with empty string filters values greater than the max distance.
{in: `{q(func: has(name)) @filter(match(name, "", 8)) {count(uid)}}`,
out: `{"data":{"q": [{"count":29}]}}`},
out: `{"data":{"q": [{"count":39}]}}`},
{in: `{q(func: has(name)) @filter(uid_in(name, "")) {count(uid)}}`,
failure: `Value "" in uid_in is not a number`},
}
Expand Down
Loading