You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "Marko A. Rodriguez (JIRA)" <ji...@apache.org> on 2015/04/28 20:57:05 UTC

[jira] [Closed] (TINKERPOP3-618) select result type varies

     [ https://issues.apache.org/jira/browse/TINKERPOP3-618?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marko A. Rodriguez closed TINKERPOP3-618.
-----------------------------------------
    Resolution: Duplicate

I believe this is part of the {{selectList}} ticket. Closing as the discussion is duplicated.

> select result type varies
> -------------------------
>
>                 Key: TINKERPOP3-618
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP3-618
>             Project: TinkerPop 3
>          Issue Type: Bug
>          Components: process
>            Reporter: Matt Frantz
>            Priority: Minor
>
> I have discovered a case where {{select}} produces a list, where previously I had assumed that only {{back}} would produce a list.  Having multiple {{as}} steps with the same label is a necessary (but not sufficient) condition.  The presence of a seemingly innocuous {{back}} step can trigger the change in behavior, but there are other conditions that are more difficult to reproduce.
> The repro is based on the {{TinkerFactory.createModern}} graph.  I have been using the {{Traverser.path}} API to try to understand the state of the path just prior to the {{select}}.
> Here is a pasteable script for the Groovy console:
> {noformat}
> g = TinkerFactory.createModern()
> g.traversal().V(1).as('a').out().as('a').out().as('a').select('a')
> g.traversal().V(1).as('a').back('a').out().as('a').out().as('a').select('a')
> debug = { it ->
>   System.err.println(it.getClass());
>   i=0;
>   it.path().forEach((java.util.function.BiConsumer){ object, labels ->
>     System.err.println(i++ + ":" + labels.toString() + " " + object)
>   })
> }
> g.traversal().V(1).as('a').out().as('a').out().as('a').sideEffect(debug).select('a')
> g.traversal().V(1).as('a').back('a').out().as('a').out().as('a').sideEffect(debug).select('a')
> {noformat}
> Here is the result on M8:
> {noformat}
> gremlin> g = TinkerFactory.createModern()
> ==>tinkergraph[vertices:6 edges:6]
> gremlin> g.traversal().V(1).as('a').out().as('a').out().as('a').select('a')
> ==>v[5]
> ==>v[3]
> gremlin> g.traversal().V(1).as('a').back('a').out().as('a').out().as('a').select('a')
> ==>[v[1], v[4], v[5]]
> ==>[v[1], v[4], v[3]]
> gremlin> debug = { it ->
> gremlin>   System.err.println(it.getClass());
> gremlin>   i=0;
> gremlin>   it.path().forEach((java.util.function.BiConsumer){ object, labels ->
> gremlin>     System.err.println(i++ + ":" + labels.toString() + " " + object)
> gremlin>   })
> gremlin> }
> ==>groovysh_evaluate$_run_closure1@5ec77191
> gremlin> g.traversal().V(1).as('a').out().as('a').out().as('a').sideEffect(debug).select('a')
> class org.apache.tinkerpop.gremlin.process.traversal.traverser.B_O_PA_S_SE_SL_Traverser
> 0:[a] v[5]
> ==>v[5]
> class org.apache.tinkerpop.gremlin.process.traversal.traverser.B_O_PA_S_SE_SL_Traverser
> 0:[a] v[3]
> ==>v[3]
> gremlin> g.traversal().V(1).as('a').back('a').out().as('a').out().as('a').sideEffect(debug).select('a')
> class org.apache.tinkerpop.gremlin.process.traversal.traverser.B_O_P_PA_S_SE_SL_Traverser
> 0:[a] v[1]
> 1:[] v[1]
> 2:[a] v[4]
> 3:[a] v[5]
> ==>[v[1], v[4], v[5]]
> class org.apache.tinkerpop.gremlin.process.traversal.traverser.B_O_P_PA_S_SE_SL_Traverser
> 0:[a] v[1]
> 1:[] v[1]
> 2:[a] v[4]
> 3:[a] v[3]
> ==>[v[1], v[4], v[3]]
> {noformat}
> Suggestion: If anyone ever wants {{select}} to return lists for the selected labels, then perhaps that use case could be explicitly supported using {{Cardinality.multi}}.  The default would be {{Cardinality.single}}, causing it to return the most recent value at the specified label.



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