question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot get properties of Elements on remote graph with scalaGraph

See original GitHub issue

Hi,

Thanks for building this nice wrapper for Scala 😄. I am currently use this on a Remote JanusGraph by calling: val scalaGraph: ScalaGraph = EmptyGraph.instance().asScala().configure(_.withRemote(DriverRemoteConnection.using(cluster, "g")))

but found I lost some syntax benefit for gremlin-scala, say, if I want to add an edge between v1 and v2, I can no logger call: val edge = v1 --- ("reference", metadata -> "EdgeTest", deleted -> false) --> v2 Exceptions below:

Edge additions not supported
java.lang.IllegalStateException: Edge additions not supported
	at org.apache.tinkerpop.gremlin.structure.Vertex$Exceptions.edgeAdditionsNotSupported(Vertex.java:175)
	at org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex.addEdge(ReferenceVertex.java:47)
	at gremlin.scala.ScalaVertex.addEdge(ScalaVertex.scala:65)
	at gremlin.scala.SemiEdge.$minus$minus$greater(SemiEdge.scala:4)

I believe this is the cause of EmptyGraph as a underlying graph. referring to this example: https://github.com/mpollmeier/gremlin-scala-examples/blob/master/dse-graph/src/test/scala/SimpleSpec.scala instead I have to call val a = StepLabel[Vertex]() val b = StepLabel[Vertex]() scalaGraph.V(v1.id).as(a).V(v2.id).as(b).addE(REFERENCE).from(a).to(b).property(metadata, "EdgeTest").property(deleted, false).iterate()

this is one of the examples that I cannot use nice wrapper provided by gremlin-scala when I am working on a remote graph, so wondering if i missed sth. here as I am still manipulating on a ScalaGraph or there is a better way to add vertex/edges in remote graph.

Thanks for your help in advance. Alex

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:37 (15 by maintainers)

github_iconTop GitHub Comments

5reactions
hudsonmdcommented, Mar 29, 2018

Turns out it was user error… You can modify my above example to add this unmodified serializer and it will function properly

 val cluster = Cluster.build()
      .addContactPoint(url)
      .port(port)
      .serializer(new GraphSONMessageSerializerV3d0())
      .create()

Thanks for the great work bringing gremlin to scala!

2reactions
Joe29commented, Nov 1, 2018

@nkconnor @mpollmeier For neptune I’m using the following setup. Still new to gremlin, so not sure how much of this is specific to issues with Neptune. I sort of walked it back from using idomatic (gremlin-)scala in a lot of areas, but am still able to use the g + CC functionality.

Like @hudsonmd said, adding the following serializer is important:

val cluster = Cluster.build()
    .addContactPoint("localhost") // with ssh tunnel to Neptune
    .port(8182)
    .serializer(new GryoMessageSerializerV3d0())
    .create()

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

And then for retrieving an item map with properties:

val userMap = g.V().has[Int](UserLabel, userIdKey, id)
        .valueMap()
        .head()

Calling the valueMap before head is important if you want properties - also calling head seems to stop a traversal, so something like .head().out() I don’t think works.

Updates for properties in neptune seem to only work if you first delete the property. I was running into this gnarly bug where if you try to increase the property value of a Double it works, but if you try to decrease it it does not.

g.V().has(UserLabel, userIdKey, uId).properties(userPropertyKey.name).drop().iterate()
g.V().has(UserLabel, userIdKey, uId).property(userPropertyKey, myPropertyValue).iterate()
Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I get a DetachedVertex rather than ReferenceVertex ...
Cannot find docs around this DetachedVertex and ReferenceVertex, ... There is no way to get "detached" graph elements using remote traversals (they might ......
Read more >
scala - Apache Gremlin Updating a Property results into ...
Here are my models and the way I have defined it. import java.util. UUID import gremlin.scala.{Element, Marshallable, Vertex ...
Read more >
mpollmeier/gremlin-scala - Gitter
What's a better way to build a Vertex with properties when you have these as ... Graph, model: V)( implicit fn: Vertex =>...
Read more >
Property Graph Server GraphViz Cannot ... - My Oracle Support
Oracle Graph Server and Client - Version 21.4 and later: Property Graph Server GraphViz Cannot Retrieve Graphs When Connected From A Remote ......
Read more >
gremlin-scala - Scaladex
A wrapper to use Apache Tinkerpop3 - a JVM graph traversal library - from ... to only return referenced elements which doesn't contain...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found