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

stephen mallette commented on TINKERPOP-793:
--------------------------------------------

This issue has mostly been about {{select()}} {{by()}}  but it also seems to 
have some applicability to {{group().by()}}.  I was writing some on Gremlin and 
noticed this:

{code}
gremlin> g.V().hasLabel('person').group().by('name').by(out('develops'))
gremlin> g.V().hasLabel('person').group().by('name').by(out('uses'))
==>[daniel:v[10], matthias:v[10], stephen:v[10], marko:v[11]]
{code}

[~dkuppitz] was quick to inform me that since {{out('develops')}} doesn't 
return anything for "daniel" in The Crew, the whole traversal returns nothing - 
so i have to do:

{code}
gremlin> g.V().hasLabel("person").group().by("name").by(out("develops").fold())
==>[daniel:[], matthias:[v[10]], stephen:[v[10], v[11]], marko:[v[10], v[11]]]
{code}

i think this generally means that I should (almost) always add {{fold()}} to 
inner traversals as it seems like the most safe way to get at what i intend.  
if it had thrown a {{FastNoSuchElementException}} it might have been hinted at 
what was wrong perhaps and then I might have realized I needed a {{fold}} or 
something, but I'm not sure new users would jump to that conclusion.  It's also 
troubling that this issue might not be as easy to diagnose on our end as 
"iterate your traversal" so when the mailing list has these kinds of issues we 
might spend a lot of time trying to solve them.

anyway, i don't think i'll get caught out by this issue again as I'll know what 
I'm looking for and I'll be sprinkling {{fold()}} in a bunch of places.  I'll 
probably get bored of sprinkling at some point and write myself a 
{{AllowNonProductiveInnerTraversalStrategy}} to auto-append my {{fold()}} steps 
for me. :)

> select should stop traversal on unproductive by
> -----------------------------------------------
>
>                 Key: TINKERPOP-793
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-793
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: process
>    Affects Versions: 3.0.2-incubating
>            Reporter: Matt Frantz
>              Labels: breaking
>
> Instead of throwing an exception, we should stop traversal if a {{by}} clause 
> fails to produce.
> Current:
> {noformat}
> gremlin> g.V().as('a').out().out().as('b')
>   .select('a', 'b')
>   .by('name')
>   .by(has('name', 'lop').values('name'))
> The provided start does not map to a value: v[5]->[HasStep([name.eq(lop)])]
> {noformat}
> Desired:
> {noformat}
> gremlin> g.V().as('a').out().out().as('b')
>   .select('a', 'b')
>   .by('name')
>   .by(has('name', 'lop').values('name'))
> ==>[a:marko, b:lop]
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to