Martin Häusler created TINKERPOP-2873:
-----------------------------------------

             Summary: 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


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)

Reply via email to