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

Improve consistency of the output of range() oriented steps

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.4.9
    • None
    • process

    Description

      As pointed out here:

      https://groups.google.com/g/gremlin-users/c/OvxKvvM8rXs/m/slnv6cWpBQAJ

      there is an automatic List unfold with limit(local, 1) as in:

      g.inject([1, 2, 3], [4]).limit(local, 3).toList() // [[1, 2, 3], [4]]
      g.inject([1, 2, 3], [4]).limit(local, 2).toList() // [[1, 2], [4]]
      g.inject([1, 2, 3], [4]).limit(local, 1).toList() // [1, 4] ??? - Expected [[1], [4]]
      g.inject([1, 2, 3], [4]).limit(local, 0).toList() // [[], []] oh come on
      

      In addition, `range()` and `tail()` are similarly affected:

      gremlin> g.inject([1, 2, 3], [4]).tail(local, 1).toList()
      ==>3
      ==>4
      gremlin> g.inject([1, 2, 3], [4]).range(local, 0, 1).toList()
      ==>1
      ==>4
      

      Changing this is a fairly imposing breaking change in behavior. We could mitigate that with a strategy to support the old functionality if folks want to have that:

      g.withStrategy(OldWayStrategy).inject([1, 2, 3], [4]).limit(local, 1)
      

      would transform to:

      g.inject([1, 2, 3], [4]).limit(local, 1).unfold()
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            spmallette Stephen Mallette
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: