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

ASF GitHub Bot commented on TINKERPOP-3178:
-------------------------------------------

spmallette opened a new pull request, #3170:
URL: https://github.com/apache/tinkerpop/pull/3170

   https://issues.apache.org/jira/browse/TINKERPOP-3178
   
   Only match on first option for switch semantics. Introduced 
Pick.unproductive when the choice ends up being unproductive. Pass through 
unproductive choices for switch semantics so that they are like if-else. 
Introduce ChooseSemantics enum to inform on whether the step is in if-else or 
switch form. Lots of documentation improvements. Please check the documentation 
for more details on exactly what changed as that was fairly detailed. 
   
   VOTE +1




> Clarify choose() with consistent semantics
> ------------------------------------------
>
>                 Key: TINKERPOP-3178
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-3178
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: process
>    Affects Versions: 3.7.3
>            Reporter: Stephen Mallette
>            Priority: Major
>              Labels: breaking
>
> h3. Match only a single case in {{choose()}}
> {code}
> gremlin> g.V().hasLabel('person').choose(values('age')).option(27, 
> constant('x')).option(27, constant('y')).option(none, constant('z'))
> ==>z
> ==>x
> ==>y
> ==>z
> ==>z
> {code}
> There should be only 4 results above, one for each person, but {{choose}} is 
> matching twice on 27.  {{choose}} should match the first item it finds only 
> and no fall through. 
> h3. Consistent behavior for unmatched inputs
> {code}
> // This passes through unmatched inputs
> g.V().choose(values('age'), values('age'))
> ==>29
> ==>27
> ==>v[3]
> ==>32
> ==>v[5]
> ==>35
> // This throws exception for unmatched inputs  
> g.V().choose(values('age')).option(27, out()).option(none, in()).path()
> The provided traverser does not map to a value: 
> v[3][TinkerVertex]->[PropertiesStep([age],value)][DefaultGraphTraversal] 
> parent[[TinkerGraphStep(vertex,[]), 
> ChooseStep([PropertiesStep([age],value)],[[none, [[VertexStep(IN,vertex), 
> EndStep]]], [(eq(27)), [VertexStep(OUT,vertex), EndStep]]]), PathStep]]
> {code}
> Change the switch form to behave like the if-then form.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to