[ 
https://issues.apache.org/jira/browse/TINKERPOP-2491?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17490499#comment-17490499
 ] 

Prashant commented on TINKERPOP-2491:
-------------------------------------

I think as a language semantic its not so straight forward to provide a special 
behavior when the limit is applied with argument 1. Not only this requires, 
handling special condition but also introduces a bug. 

 
# Queries run in modern graph. 

gremlin> g.V().local(out().fold()).limit(local,2)
==>[v[3],v[2]]
==>[]
==>[]
==>[v[3],v[5]]
==>[]
==>[v[3]]

gremlin> g.V().local(out().fold()).limit(local,1)
==>v[3]

# Bug with empty list :D 
# does not return elements from container lesser than size 1 and throws 
exception. 
# Doesn't return results for further results.

gremlin> g.V('3').in().local(out().fold()).limit(local,1)
==>v[3]
==>v[3]
==>v[3]
So when limit(local,1 ) is applied on empty list, it throws an exception 
because there is no empty container created for those results. 

However, this works fine when local limit is used for more than 1 solutions. 

 

I think it is better to have generic implementation without unfold semantic 
with limit(local,1).

 

 

> Improve consistency of the output of range() oriented steps
> -----------------------------------------------------------
>
>                 Key: TINKERPOP-2491
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2491
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: process
>    Affects Versions: 3.4.9
>            Reporter: Stephen Mallette
>            Assignee: Stephen Mallette
>            Priority: Major
>              Labels: breaking
>
> As pointed out here:
> https://groups.google.com/g/gremlin-users/c/OvxKvvM8rXs/m/slnv6cWpBQAJ
> there is an automatic {{List}} unfold with {{limit(local, 1)}} as in:
> {code}
> g.inject([1, 2, 3], [4]).limit(local, 3).toList() // [[1, 2, 3], [4]]
> g.inject([1, 2, 3], [4]).limit(local, 2).toList() // [[1, 2], [4]]
> g.inject([1, 2, 3], [4]).limit(local, 1).toList() // [1, 4] ??? - Expected 
> [[1], [4]]
> g.inject([1, 2, 3], [4]).limit(local, 0).toList() // [[], []] oh come on
> {code}
> In addition, `range()` and `tail()` are similarly affected:
> {code}
> gremlin> g.inject([1, 2, 3], [4]).tail(local, 1).toList()
> ==>3
> ==>4
> gremlin> g.inject([1, 2, 3], [4]).range(local, 0, 1).toList()
> ==>1
> ==>4
> {code}
> Changing this is a fairly imposing breaking change in behavior. We could 
> mitigate that with a strategy to support the old functionality if folks want 
> to have that:
> {code}
> g.withStrategy(OldWayStrategy).inject([1, 2, 3], [4]).limit(local, 1)
> {code}
> would transform to:
> {code}
> g.inject([1, 2, 3], [4]).limit(local, 1).unfold()
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to