Uploaded image for project: 'TinkerPop'
  1. TinkerPop
  2. TINKERPOP-2873

Allow Union of Traversals

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Done
    • 3.6.2
    • 3.7.0
    • language
    • None

    Description

      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:

      g.traversal().union(t1, t2, t3) ...  // traversal continues here
      

      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:

      g.traversal().inject(0).union(t1, t2, t3) ...  // traversal continues here
      

      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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              martin.haeusler Martin Häusler
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: