[
https://issues.apache.org/jira/browse/TINKERPOP3-715?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14578003#comment-14578003
]
Marko A. Rodriguez commented on TINKERPOP3-715:
-----------------------------------------------
{{optional()}} would be like the "traversal version" of sideEffect much like
{{where()}} for filter and {{local()}} for map/flatMap.
> [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)