是否可以使用V(select(“ id”))

时间:2019-06-18 14:04:02

标签: gremlin

我想在不使用长遍历的情况下修改多个顶点的属性(请参见http://tinkerpop.apache.org/docs/current/recipes/#long-traversals)。出于性能原因,我在本地缓存了一个顶点ID。

我想编写类似(在Tinkerpop 3.3.3上)的代码:

var list = [ ["id": 123, "prop": "foo"], ["id": 456, "prop": "bar"] ];
g.inject(list)
    .unfold()
    .as("map")
    .V(__.select("id"))
    .property("prop", __.select("map").select("prop"))
    .iterate();

但是我遇到了以下异常:

java.lang.IllegalArgumentException: Expected an id that is convertible to Long but received class com.dcbrain.flowengine.dsl.DefaultFlowEngineTraversal
    at org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph$DefaultIdManager$1.convert(TinkerGraph.java:587)
    at org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph.lambda$createElementIterator$4(TinkerGraph.java:316)

有没有解决方法,或者其他Tinkerpop版本支持此方法吗?

1 个答案:

答案 0 :(得分:0)

我发现了另一种创建查询的方法:

var map= [ 123 : "foo"], [456 : "bar"];
g.withSideEffect("map", map)
    .V(map.keySet().toArray())
    .as("id")
    .property("prop", __.select("map").select(__.select("id").by(T.id)))
    .iterate();