是否可以判断Gremlin Drop()步骤是否做了什么? [英] Is it possible to tell whether a Gremlin Drop() step did anything?

查看:188
本文介绍了是否可以判断Gremlin Drop()步骤是否做了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个遍历,以drop()结尾,以删除一个顶点.我希望能够说出drop()删除顶点与遍历之间的区别只是不匹配任何东西.

I have a traversal that ends with a drop() to delete a vertex. I would like to be able to tell the difference between the drop() removing a vertex and the traversal just not matching anything.

我尝试将别名添加到较早的节点之一,并在遍历结束时对其进行select()处理,但这即使遍历与图形匹配也不会返回任何内容.

I tried adding an alias to one of the earlier nodes and select()ing it at the end of the traversal, but that doesn't return anything even when the traversal does match the graph.

例如

g.V('id', '1').as('flag')
.out('has_child')
.drop()
.select('flag')
.toList()

推荐答案

诀窍在于,drop()是筛选步骤,因此可以从遍历流中删除对象.您可以通过按sideEffect()来解决此情况:

The trick is that drop() is a filter step so it removes objects from the traversal stream. You can work around that situation a bit by dropping by sideEffect():

gremlin> g.V().has('person','name','marko')
==>v[1]
gremlin> g.V().has('person','name','marko').sideEffect(drop())
==>v[1]
gremlin> g.V().has('person','name','marko')
gremlin>

顶点的返回意味着存在并删除了该顶点,但是如果不返回任何值,则它在第一个要删除的位置上就不存在.

The return of the vertex would mean that it was present and dropped, but if no value is returned then it wasn't present in the first place to be dropped.

这篇关于是否可以判断Gremlin Drop()步骤是否做了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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