【问题标题】:AWS Neptune transaction supportAWS Neptune 事务支持
【发布时间】:2018-09-24 12:42:35
【问题描述】:

Neptune 目前只支持 OLTP 类型的图遍历查询?

但是来自documentation

交易 Neptune 在每次 Gremlin 遍历开始时打开一个新事务,并在成功完成遍历后关闭该事务。出错时事务回滚。

由分号 (;) 或换行符 (\n) 分隔的多个语句包含在单个事务中。 除了最后一个语句之外的每个语句都必须以 next() 步骤结束执行。只返回最终的遍历数据。

不支持使用 tx.commit() 和 tx.rollback() 的手动事务逻辑。

由分号或换行符分隔的多个语句在单个事务中执行。那么,您可以在每个事务中执行多个查询吗?例如单个脚本中的多个 .drop() 查询?

g.V().has(id,'1').drop();
g.V().has(id,'2').drop();

通过上面的尝试,只执行了最后一个查询(只删除了 id='2' 的顶点)。

但是对于添加顶点,它可以工作:

g.addV('item').property(id,'3').next()";
g.addV('item').property(id,'4').next()";

两个顶点都被添加了。

是否支持单个事务中的多个删除查询?

【问题讨论】:

    标签: gremlin amazon-neptune


    【解决方案1】:

    只是一个猜测,但我认为您可能需要 iterate() 您的遍历,因此:

    g.V().has(id,'1').drop().iterate();
    g.V().has(id,'2').drop().iterate();
    

    鉴于您使用addV() 的示例以及您使用drop() 看到的行为,最后一次遍历是唯一自动迭代的,这与Gremlin Server 通常处理脚本请求的方式一致。我猜 Neptune 也会以同样的方式工作。

    【讨论】:

    • 谢谢!有效。最后我错误地尝试了 .next() 。来自文档:iterate() does not exactly fit the definition of a terminal step in that it doesn’t return a result, but still returns a traversal - it does however behave as a terminal step in that it iterates the traversal and generates side effects without returning the actual result.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-06
    • 2019-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多