Marko A. Rodriguez created TINKERPOP3-715:
---------------------------------------------

             Summary: [Proposal] Do we need a optional(traversal) like in 
TinkerPop2?
                 Key: TINKERPOP3-715
                 URL: https://issues.apache.org/jira/browse/TINKERPOP3-715
             Project: TinkerPop 3
          Issue Type: New Feature
            Reporter: Marko A. Rodriguez


In TinkerPop2 we had {{optional()}}. It allowed the traverser to go down the 
{{optional}}-branch and its results were only used for their sideEffects. For 
instance:

{code}
g.V(x).optional(out('rated').aggregate('userLibrary'))
  .outE('rated').has('stars',gte(4)).inV()
  .inE('rated').has('stars',gte(4)).inV()
  .outE('rated').has('stars',gte(4)).inV().where(not(within('userLibrary')))
    .groupCount()
{code}

To do this in TinkerPop3, we would do:

{code}
g.V(x).sideEffect(v -> 
g.V(v.get()).out('rated').aggregate('userLibrary').iterate())
  .outE('rated').has('stars',gte(4)).inV()
  .inE('rated').has('stars',gte(4)).inV()
  .outE('rated').has('stars',gte(4)).inV().where(not(within('userLibrary')))
    .groupCount()
{code}

... :/ ... should we add {{optional}} back in the mix? It would be like 
{{.as('a').local(...).select('a')}} but it would not care if the nested 
traversal returned a result or not.




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

Reply via email to