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

Enhance sample().by() semantics when by produces a null

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Done
    • 3.5.1
    • 3.6.0
    • process

    Description

      We currently get a NPE for this:

      gremlin> g.V().sample(1).by("age")
      java.lang.NullPointerException
      Type ':help' or ':h' for help.
      Display stack trace? [yN]
      

      Since sample() is a filter, it seems intuitive that it could remove traversers that don't resolve in the by(). Of course, that changes the current semantics when the sample size is greater than or equal to the size of the traverser set:

      gremlin> g.V().sample(6).by("age")
      ==>v[1]
      ==>v[2]
      ==>v[3]
      ==>v[4]
      ==>v[5]
      ==>v[6]
      

      As an aside, we might also improve this error messaging:

      gremlin> g.V().sample(1).by("name")
      class java.lang.String cannot be cast to class java.lang.Number (java.lang.String and java.lang.Number are in module java.base of loader 'bootstrap')
      Type ':help' or ':h' for help.
      Display stack trace? [yN]
      

      As this would change Gremlin semantics a bit, it should target the next breaking version.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: