mpollmeier / gremlin-scala

[unmaintained] Scala wrapper for Apache TinkerPop 3 Graph DSL
Apache License 2.0
482 stars 75 forks source link

With Sack not initialising properly. #297

Open karlmvwaugh opened 3 years ago

karlmvwaugh commented 3 years ago

I'm using gremlin-scala to talk to a Neptune instance. Trying to use WithSack in a traversal I kept getting the error

Caused by: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: An error occurred during serialization of this request [RequestMessage{, requestId=f2258d63-4265-499e-9684-dde9b007e0d1, op='bytecode', processor='traversal', args={gremlin=[[withSack(gremlin.scala.package$$anon$1@19e943ef)], [V(), limit(5)]], aliases={g=g}}}] - it could not be sent to the server - Reason: org.apache.tinkerpop.gremlin.driver.ser.SerializationException: java.lang.IllegalArgumentException: Class is not registered: gremlin.scala.package$$anon$1

I attempted multiple variations on syntax to get it to work. traversalSource.withSack(1.0) is my intended usage.

In the end I can get it working by emulating the underlying call but without using a lambda. That is:

TraversalSource(traversalSource.underlying.withSack[Double](1.0))

but if I try this with a lambda that returns a double it doesn't work and the libraries implementation of the constant version falls back on the lambda version.

jeremysears commented 3 years ago

I think this is a bug in TraversalSource.withSack[A](initial: A). I think this:

def withSack[A](initialValue: A): TraversalSource =
    withSack(() => initialValue)

Should be:

def withSack[A](initialValue: A) =
    TraversalSource(underlying.withSack(initialValue))

Feel free to submit a PR.

I haven't worked with Neptune, but for lambdas in general, it would be nice if gremlin-scala had some support for something like this, even if it wasn't type safe. I may evaluate JanusGraph with BigTable at some point, and if I do, I may poke at lambda support w/ remote DBs. https://tinkerpop.apache.org/docs/current/reference/#gremlin-java-lambda