如何链接Gremlin中的命令? [英] How to chain commands in Gremlin?

查看:274
本文介绍了如何链接Gremlin中的命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下命令可以工作

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

以下命令可以工作

  t = new Table(); $('id')。as('properties')。table(t){it.id} {it.map}; 
g.V.as打印t

以下命令不起作用

  t = new Table(); 。g.V.as( ID),为(属性)表(t)的{it.id} {it.map};打印t 

为什么?

解决方案

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

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

例如,为了使你以前的命令工作, (注意>> - 1):

  t = new Table(); g.V.as( ID),为(属性)表(t)的{it.id} {it.map}> -1个; print t 

有关更多信息,请阅读Gremlin文档的疑难解答部分中的第一个问题:
https://github.com/tinkerpop/gremlin/wiki/Troubleshooting Pipes )。最好这样做:

  gVas('id')._。as。('properties')。table t){it.id} {it.map} 

也就是说,在两个作为()的步骤。



希望有帮助,
Marko。


http://markorodriguez.com


The following command works

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

The following command works

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

The following command doesn't work

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

Why?

解决方案

The fast answer: You need to iterate your pipeline.

The long answer: In the Gremlin REPL, iteration will happen for you automagically if your last statement is an iterator or iterable. However, if you last statement is not (e.g. println t), then you must manually iterate your iterator/iterable.

For example, to make your previous command work, do (note the >>-1):

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

For more information, read the first issue in the troubleshooting section of the Gremlin documentation: https://github.com/tinkerpop/gremlin/wiki/Troubleshooting

Next, while you didn't ask this question, you will run into ordering issues when you have two as() steps in a row. The AsPipe is a MetaPipe in that it wraps the Pipe/step previous to it (Gremlin is based on Pipes). It is best to do this:

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

That is, insert an identity step between the two as() steps.

Hope that helps, Marko.

http://markorodriguez.com

这篇关于如何链接Gremlin中的命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆