graph - 如何在 Gremlin 中链接命令?

标签 graph neo4j graph-databases gremlin

下面的命令有效

t = new Table(); g.V.as('id').as('properties').table(t){it.id}{it.map}
print t

下面的命令有效

t = new Table();
g.V.as('id').as('properties').table(t){it.id}{it.map}; print t

下面的命令不起作用

t = new Table(); g.V.as('id').as('properties').table(t){it.id}{it.map}; print t

为什么?

最佳答案

快速回答:您需要迭代管道。

长答案:在 Gremlin REPL 中,如果您的最后一条语句是迭代器或可迭代的,迭代将自动为您发生。但是,如果您的最后一条语句不是(例如 println t),那么您必须手动迭代您的迭代器/可迭代对象。

例如,要使您之前的命令生效,请执行(注意 >>-1):

t = new Table(); g.V.as('id').as('properties').table(t){it.id}{it.map}>>-1; print t

有关更多信息,请阅读 Gremlin 文档的故障排除部分中的第一期: https://github.com/tinkerpop/gremlin/wiki/Troubleshooting

接下来,虽然您没有问这个问题,但当您连续执行两个 as() 步骤时,您会遇到排序问题。 AsPipe 是一个 MetaPipe,因为它包装了它之前的管道/步骤(Gremlin 基于 Pipes )。最好这样做:

g.V.as('id')._.as('properties').table(t){it.id}{it.map}

即在两个as()步骤之间插入一个identity步骤。

希望对你有帮助, 马尔科。

http://markorodriguez.com

关于graph - 如何在 Gremlin 中链接命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7433802/

相关文章:

hadoop - 有向图中的 MapReduce 长度为 3 条路径

php - 将一条记录限制为 Cypher COLLECTION

algorithm - Neo4j使用的访问算法

c# - .NET 图形数据库

neo4j - 查找最常用的不同术语集

algorithm - 在图中找到距离至少为 D(常数) 的两条路径

iphone - x Axis 上带有月份的核心图 (iphone)

python - OSM 到有向图 (python-igraph/networkx)

csv - Neo4j 批量导入中作为 int 的 ID 在关系导入中产生错误

.net - 寻找分布式内存中图形数据库