1

Im using Gremlin-scala 3.4.1.5 against Neptune and I'm unable to add a vertex using a case class with a List or Set like so. Add vertex seems to work when that doesn't exist

//connection
Cluster.build()
      .addContactPoint(endpoint)
      .serializer(new GraphSONMessageSerializerV3d0())
      .port(port)
      .create()

val g = EmptyGraph.instance.asScala().configure(_.withRemote(DriverRemoteConnection.using(cluster)))

// adding vertex

case class Person(name: String, friends: Seq[String])
case class Person(name: String, friends: Set[String]) // also does not work
g + Person

Stack Trace

org.apache.tinkerpop.gremlin.driver.exception.ResponseException: {"requestId":-087f-4868-b4b7-","code":"UnsupportedOperationException","detailedMessage":"Unsupported property value type: java.util.LinkedHashMap"}
java.util.concurrent.CompletionException: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: {"requestId":"-087f-4868-b4b7-","code":"UnsupportedOperationException","detailedMessage":"Unsupported property value type: java.util.LinkedHashMap"}
    at java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:375)
    at java.util.concurrent.CompletableFuture.join(CompletableFuture.java:1934)
    at org.apache.tinkerpop.gremlin.driver.ResultSet.one(ResultSet.java:119)
    at org.apache.tinkerpop.gremlin.driver.ResultSet$1.hasNext(ResultSet.java:171)
    at org.apache.tinkerpop.gremlin.driver.ResultSet$1.next(ResultSet.java:178)
    at org.apache.tinkerpop.gremlin.driver.ResultSet$1.next(ResultSet.java:165)
    at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal$TraverserIterator.next(DriverRemoteTraversal.java:140)
    at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal$TraverserIterator.next(DriverRemoteTraversal.java:125)
    at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal.nextTraverser(DriverRemoteTraversal.java:106)
Bowofola
  • 1,132
  • 9
  • 12

3 Answers3

0

Re Unsupported property value type: java.util.LinkedHashMap

I don't have a working neptune setup, but a plain scala List might work. If not, here's the relevant sections in the macro:

https://github.com/mpollmeier/gremlin-scala/blob/2e32ae0/macros/src/main/scala/gremlin/scala/Marshallable.scala#L178-L179

https://github.com/mpollmeier/gremlin-scala/blob/2e32ae0/macros/src/main/scala/gremlin/scala/Marshallable.scala#L110-L120

Michael Pollmeier
  • 1,370
  • 11
  • 20
0

I believe Neptune may not support list properties on vertices as per this documentation: https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-differences.html

To test this, you could try running the same code against gremlin-server or some other implementation

Cody Braun
  • 659
  • 6
  • 17
  • Thats about `List` cardinality. My case class has a list, but using a library like gremlin-scala I shouldn't care how it handles it. I expect it to just get it into the database, and get it back out. – Bowofola Jun 27 '19 at 19:32
0

Neptune does not support List as a property type [1]. If an ordered list is required, one way to do it is to serialize it into a single property (eg: json string of the list). It does need a bit of logic in the application layer to read it back properly. Another common way to do lists is to model your list item as a vertex on its own, and model them as edges in the graph.

Eg: Instead of having a property for the list of Addresses, make Address a vertex Label, and have edges from your Person to Address1 to Address2. This option is better if you anticipate mutations to your list.

https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-differences.html

Update

Accepting this as answer because that's what I ended up using. I would just like to clarify a few things.

Neptune supports Single and Set cardinality properties when using the Gremlin property() step etc.

I have opened an issue in Gremlin-scala because I believe the native TinkerPop cardinalities should be supported for List and Set. List would fail in Neptune today but that's fine because the user can switch to Set if it worked for their use case and that would work.

Community
  • 1
  • 1
The-Big-K
  • 2,672
  • 16
  • 35
  • I've already gone with option A. I dont want to add more vertices for things that dont need to be vertices cause that explodes with versioning etc. Easiest way is to just handle json serDe by myself. Also, Neptune supports Set cardinality and yet gremlin-scala does not handle it. Neptune doesn't support any of them directly and this I already knew. – Bowofola Jun 27 '19 at 19:36