You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "Stephen Mallette (Jira)" <ji...@apache.org> on 2023/02/22 12:14:00 UTC

[jira] [Commented] (TINKERPOP-2873) Allow Union of Traversals

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

Stephen Mallette commented on TINKERPOP-2873:
---------------------------------------------

i tend to agree with you these days. i do worry a bit about misuse but then you could misuse the {{inject(0}} patterns so i'm not sure there is a difference. since this is a language change you are requesting could you please send an email to the dev list as a "DISCUSS" thread and call attention to what you are requesting and link this issue.

> Allow Union of Traversals
> -------------------------
>
>                 Key: TINKERPOP-2873
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2873
>             Project: TinkerPop
>          Issue Type: New Feature
>          Components: language
>    Affects Versions: 3.6.2
>            Reporter: Martin Häusler
>            Priority: Minor
>
> Currently, it is possible to use the gremlin "union(...)" step as a union based on *traversers*. The union takes each incoming traverser, and clones it for each sub-traversal and feeds it to the sub-traversal as input.
> There is another type of union, which relates more to a SQL "UNION ALL" command. This second type of union is the union of *Traversals*. So we have *independent* traversals with their own start and end steps, and we want to combine them into a single traversal. The outcome of this traversal is the union of the outcome of all sub-traversals.
> One way to achieve this would be to allow "union(...)" step as the initial step for a traversal:
> {code:java}
> g.traversal().union(t1, t2, t3) ...  // traversal continues here
> {code}
> The purpose of this mechanism is:
> * The root traversal after the "union(...)" step has access to all of the labels and side effect keys of the sub-traversals and can operate on them.
> * The root traversal can operate on the resulting traversers and continue to filter them, perform navigation steps, etc.
> Currently, the workaround for this kind of "traversal union" is:
> {code:java}
> g.traversal().inject(0).union(t1, t2, t3) ...  // traversal continues here
> {code}
> Here, we inject a dummy value of 0 into the traversal which only exists to trigger the union step, where it is discarded immediately by all alternatives (which come with their own start steps). This works as intended and also shares side effect keys etc. but is syntactically unpleasant and rather confusing to read.



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