在Janusgraph中,EdgeID以字母数字形式返回,而不是以LONG形式返回 [英] edgeID is returned as alpha numeric instead of long in Janusgraph
本文介绍了在Janusgraph中,EdgeID以字母数字形式返回,而不是以LONG形式返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用以下代码创建边
Edge e = this.g
.V(fromId) // get vertex of id given for the source
.as("fromVertex") // label as fromVertex to be accessed later
.V(toId) // get vertex of id given for destination
.coalesce( // evaluates the provided traversals in order and returns the first traversal that emits at least one element
inE(label) // check incoming edge of label given
.where( // conditional check to check if edge exists
outV() // get destination vertex of the edge to check
.as("fromVertex")), // against staged vertex
addE(label) // add edge if not present
.from("fromVertex"))
.next(); // end traversal to commit to graph
System.out.println(Long.parseLong(e.id().toString());
这会将edgeID打印为1lb-394-36d-38
。结果,我得到了NumberFormatException。我以为默认情况下所有ID都很长。是否需要配置某些内容?
这是我的当前配置
gremlin.graph=org.janusgraph.core.JanusGraphFactory
storage.backend=berkeleyje
storage.directory=jgex/berkeleyje
index.jgex.backend=lucene
index.jgex.directory=jgex/lucene
我在gremlin控制台上尝试了同样的操作,不管我执行了多少次,我都得到了一个预期的长ID。我这样做是为了查看coalesce
是否导致问题
gremlin> g.V(0L).as("fromVertex").V(2L).coalesce(inE("MIXES_WITH").where(outV().as("fromVertex")), addE("MIXES_WITH").from("fromVertex")).next().id()
==>6
gremlin> g.V(0L).as("fromVertex").V(2L).coalesce(inE("MIXES_WITH").where(outV().as("fromVertex")), addE("MIXES_WITH").from("fromVertex")).next().id()
==>6
gremlin> g.V(0L).as("fromVertex").V(2L).coalesce(inE("MIXES_WITH").where(outV().as("fromVertex")), addE("MIXES_WITH").from("fromVertex")).next().id()
==>6
推荐答案
JanusGraph中的Edge ID是使用名为RelationIdentifier的特殊类存储的,该类包含的信息比ID本身多得多。该类的ID是与";uuid类似的";标识符。你可以从班上获得其他信息。下面是一个使用Gremlin控制台中的简单‘inMemory’JanusGraph的示例。
gremlin> g.addV('a').as('a').addV('b').as('b').addE('test').from('a').to('b')
==>e[16p-360-2dx-9jk][4104-test->12368]
gremlin> g.V().hasLabel('a').outE().next().class
==>class org.janusgraph.graphdb.relations.StandardEdge
gremlin> g.V().hasLabel('a').outE().id().next().class
==>class org.janusgraph.graphdb.relations.RelationIdentifier
gremlin> g.V().hasLabel('a').outE().id().next().class.methods
==>public long org.janusgraph.graphdb.relations.RelationIdentifier.getTypeId()
==>public long org.janusgraph.graphdb.relations.RelationIdentifier.getOutVertexId()
==>public long org.janusgraph.graphdb.relations.RelationIdentifier.getInVertexId()
==>public long[] org.janusgraph.graphdb.relations.RelationIdentifier.getLongRepresentation()
==>public long org.janusgraph.graphdb.relations.RelationIdentifier.getRelationId()
==>public static org.janusgraph.graphdb.relations.RelationIdentifier org.janusgraph.graphdb.relations.RelationIdentifier.get(int[])
==>public static org.janusgraph.graphdb.relations.RelationIdentifier org.janusgraph.graphdb.relations.RelationIdentifier.get(long[])
==>public boolean org.janusgraph.graphdb.relations.RelationIdentifier.equals(java.lang.Object)
==>public java.lang.String org.janusgraph.graphdb.relations.RelationIdentifier.toString()
==>public int org.janusgraph.graphdb.relations.RelationIdentifier.hashCode()
==>public static org.janusgraph.graphdb.relations.RelationIdentifier org.janusgraph.graphdb.relations.RelationIdentifier.parse(java.lang.String)
==>public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException
==>public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException
==>public final void java.lang.Object.wait() throws java.lang.InterruptedException
==>public final native java.lang.Class java.lang.Object.getClass()
==>public final native void java.lang.Object.notify()
==>public final native void java.lang.Object.notifyAll()
gremlin> g.V().hasLabel('a').outE().id().next().getRelationId()
==>1537
这篇关于在Janusgraph中,EdgeID以字母数字形式返回,而不是以LONG形式返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文