edgeID 在 Janusgraph 中返回为字母数字而不是 long

edgeID is returned as alpha numeric instead of long in Janusgraph

我使用下面的代码来创建边

        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 中的边 ID 使用一种名为 RelationIdentifier 的特殊 class 存储,它包含的信息远不止 ID 本身。 class 的 ID 是一个“类似 UUID”的标识符。您可以从 class 中获取其他信息。下面是一个使用来自 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