Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find the vertex which has multiple values when loading the graphson from file #229

Open
JoeyKu opened this issue Jan 29, 2018 · 2 comments

Comments

@JoeyKu
Copy link

JoeyKu commented Jan 29, 2018

Here is the source code:

// create graphson object and dump it to the file graphson.txt
  val g = TinkerGraph.open()
  val gScala = g.asScala
  val v = gScala.addVertex("Node", ("ip", "192.168.1.1"), ("ip", "192.168.1.2"), ("ip", "192.168.1.3"))
  val mapper = g.io(IoCore.graphson).mapper.normalize(true).version(GraphSONVersion.V2_0).create
  g.io(IoCore.graphson).writer.mapper(mapper).create.writeGraph(new FileOutputStream("./graphson.txt"), g)

  println(gScala.V().hasLabel("Node").has(Key[String]("ip"), "192.168.1.1").headOption())  // Some(v[0]) 
  println(gScala.V().hasLabel("Node").has(Key[String]("ip"), "192.168.1.2").headOption())  // Some(v[0])
  println(gScala.V().hasLabel("Node").has(Key[String]("ip"), "192.168.1.3").headOption())  // Some(v[0])

  // load it from file
  val gNew = TinkerGraph.open()
  val gScalaNew = gNew.asScala()

  val s: InputStream = new FileInputStream("./graphson.txt")
  gNew.io(IoCore.graphson()).reader().create().readGraph(s, gNew)

  // try to operate it
  println(gScalaNew.V().hasLabel("Node").has(Key[String]("ip"), "192.168.1.1").headOption())  // None (Why this is None?)
  println(gScalaNew.V().hasLabel("Node").has(Key[String]("ip"), "192.168.1.2").headOption())  // None (Why this is None?)
  println(gScalaNew.V().hasLabel("Node").has(Key[String]("ip"), "192.168.1.3").headOption())  // Some(v[0])
@mpollmeier
Copy link
Owner

you forgot to send the imports and key definition, I'm assume you're using this:

import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
import gremlin.scala._
import scala.collection.JavaConverters._
import org.apache.tinkerpop.gremlin.structure.io.IoCore
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion
import java.io.FileOutputStream
import java.io.FileInputStream
import java.io.InputStream

val KeyString = Key[String]("ip")

When you switch to graphML you see what's wrong:
g.io(IoCore.graphml).writeGraph("./graphml.xml")
leads to: Multiple properties exist for the provided key, use Vertex.properties(ip) at org.apache.tinkerpop.gremlin.structure.Vertex$Exceptions.multiplePropertiesExistForProvidedKey(Vertex.java:179)

Looks like there's a problem with multi-properties and graph serialisation in gremlin-core. I've just tried it with gremlin-groovy which has the same problem:

graph = TinkerGraph.open()
g = graph.traversal()
v = g.addV().property('name','marko').property('name','marko a. rodriguez').next()
g.V(v).properties('name').count() //2

graph.io(IoCore.graphml()).writeGraph("multiprop.xml")
// error: Multiple properties exist for the provided key, use Vertex.properties(name)

In other words: it's not a gremlin-scala issue. Please ask on https://groups.google.com/forum/#!forum/gremlin-users about this and/or open an issue in jira: https://issues.apache.org/jira/projects/TINKERPOP/issues

@aselamal
Copy link

I just stumbled across this as well, and it seems like Tinkerpop won't support graphML export when List/Set cardinality is used.

https://issues.apache.org/jira/browse/TINKERPOP-1935

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants