【问题标题】:Is V(select("id")) possibleV(select("id")) 可能吗
【发布时间】:2019-06-18 14:04:02
【问题描述】:

我想在不使用长遍历的情况下修改多个顶点的属性(请参阅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 版本是否支持此功能?

【问题讨论】:

    标签: gremlin


    【解决方案1】:

    我找到了另一种创建查询的方法:

    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();
    

    【讨论】:

      猜你喜欢
      • 2011-08-12
      • 2017-11-30
      • 2012-05-07
      • 1970-01-01
      • 2021-04-29
      • 2017-08-17
      • 2014-02-14
      • 2015-01-22
      • 1970-01-01
      相关资源
      最近更新 更多