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

Some conditions on traverse won't work with breadth_first strategy #5333

Closed
giacomoParigi opened this issue Nov 17, 2015 · 0 comments
Closed
Assignees
Labels

Comments

@giacomoParigi
Copy link

This is the second issue obtained from this wider problem: #5314 (you can find the first one here: #5330 )

Some specific conditions of the while statement in the traverse operator won't work when the chosen strategy is breadth_first. The only way to make them work is to add the limit keyword, but in this case the strategy breadth_first statement will be ignored (as pointed out here: #5330 )

The broken query is (together with some variations):

select $current.traversedVertex(-1), $path from
(
    traverse * from #13:0
        while
        traversedVertex(-1)=traversedVertex(0)
        or traversedVertex(-1).@class <> traversedVertex(0).@class
    strategy breadth_first
)
limit -1

On the public dbs openBeer and Whisky this query will just run for hours (one night at least), while on smaller dbs it will return only the starting node. The script attached is a simple example (in the same form of the ones at #5314 ) that gives these results:

  1. breadth_first without limit keyword
select $current.traversedVertex(-1), $path from
(
    traverse * from #13:0
        while
        traversedVertex(-1)=traversedVertex(0)
        or traversedVertex(-1).@class <> traversedVertex(0).@class
    strategy breadth_first
)
limit -1

Results:

$current $path
#13:0 (#13:0)
  1. breadth_first with limit keyword
select $current.traversedVertex(-1), $path from
(
    traverse * from #13:0
        while
        traversedVertex(-1)=traversedVertex(0)
        or traversedVertex(-1).@class <> traversedVertex(0).@class
    limit -1
    strategy breadth_first
)
limit -1

Results (note the depth_first order):

$current $path
#13:0 (#13:0)
#13:0 (#13:0).out_CtoA0
#11:0 (#13:0).out_CtoA0.in(#11:0)
#11:0 (#13:0).out_CtoA0.in(#11:0).out_AtoB0
#12:0 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0)
#11:1 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).in_AtoB1
#11:1 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).in_AtoB1.out(#11:1)
#13:0 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).in_AtoB1.out(#11:1).in_CtoA0
#11:1 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).in_AtoB1.out(#11:1).out_toOther0
#14:1 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).in_AtoB1.out(#11:1).out_toOther0.in(#14:1)
#14:1 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).in_AtoB1.out(#11:1).out_toOther0.in(#14:1).out_toOther0
#14:5 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).in_AtoB1.out(#11:1).out_toOther0.in(#14:1).out_toOther0.in(#14:5)
#13:0 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).in_CtoB0
#12:0 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).out_toOther0
#14:2 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).out_toOther0.in(#14:2)
#14:2 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).out_toOther0.in(#14:2).out_toOther0
#14:6 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).out_toOther0.in(#14:2).out_toOther0.in(#14:6)
#11:0 (#13:0).out_CtoA0.in(#11:0).out_toOther0
#14:0 (#13:0).out_CtoA0.in(#11:0).out_toOther0.in(#14:0)
#14:0 (#13:0).out_CtoA0.in(#11:0).out_toOther0.in(#14:0).out_toOther0
#14:4 (#13:0).out_CtoA0.in(#11:0).out_toOther0.in(#14:0).out_toOther0.in(#14:4)
#13:0 (#13:0).out_toOther0
#14:3 (#13:0).out_toOther0.in(#14:3)
#14:3 (#13:0).out_toOther0.in(#14:3).out_toOther0
#14:7 (#13:0).out_toOther0.in(#14:3).out_toOther0.in(#14:7)
  1. depth_first (limit keyword has no effects apart from the documented ones)
select $current.traversedVertex(-1), $path from
(
    traverse * from #13:0
        while
        traversedVertex(-1)=traversedVertex(0)
        or traversedVertex(-1).@class <> traversedVertex(0).@class
    strategy depth_first
)
limit -1

Results (Wrongly equal to query number 2):

$current $path
#13:0 (#13:0)
#13:0 (#13:0).out_CtoA0
#11:0 (#13:0).out_CtoA0.in(#11:0)
#11:0 (#13:0).out_CtoA0.in(#11:0).out_AtoB0
#12:0 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0)
#11:1 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).in_AtoB1
#11:1 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).in_AtoB1.out(#11:1)
#13:0 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).in_AtoB1.out(#11:1).in_CtoA0
#11:1 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).in_AtoB1.out(#11:1).out_toOther0
#14:1 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).in_AtoB1.out(#11:1).out_toOther0.in(#14:1)
#14:1 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).in_AtoB1.out(#11:1).out_toOther0.in(#14:1).out_toOther0
#14:5 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).in_AtoB1.out(#11:1).out_toOther0.in(#14:1).out_toOther0.in(#14:5)
#13:0 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).in_CtoB0
#12:0 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).out_toOther0
#14:2 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).out_toOther0.in(#14:2)
#14:2 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).out_toOther0.in(#14:2).out_toOther0
#14:6 (#13:0).out_CtoA0.in(#11:0).out_AtoB0.in(#12:0).out_toOther0.in(#14:2).out_toOther0.in(#14:6)
#11:0 (#13:0).out_CtoA0.in(#11:0).out_toOther0
#14:0 (#13:0).out_CtoA0.in(#11:0).out_toOther0.in(#14:0)
#14:0 (#13:0).out_CtoA0.in(#11:0).out_toOther0.in(#14:0).out_toOther0
#14:4 (#13:0).out_CtoA0.in(#11:0).out_toOther0.in(#14:0).out_toOther0.in(#14:4)
#13:0 (#13:0).out_toOther0
#14:3 (#13:0).out_toOther0.in(#14:3)
#14:3 (#13:0).out_toOther0.in(#14:3).out_toOther0
#14:7 (#13:0).out_toOther0.in(#14:3).out_toOther0.in(#14:7)

TraversedVertex_BreadthFirst_check3.txt

@lvca lvca added this to the 2.1.x (next hotfix) milestone Nov 18, 2015
@lvca lvca added the bug label Nov 18, 2015
@lvca lvca modified the milestones: 2.1.x (next hotfix), 2.1.6 Nov 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants