Gremlin:GroupBy顶点,计数> 1 [英] Gremlin : GroupBy vertices , having count > 1

查看:508
本文介绍了Gremlin:GroupBy顶点,计数> 1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用TITAN 0.4和gremlin进行遍历。
我的要求是在图中标识重复的顶点,并合并它们。
图中有> 15 M个顶点。

  gremlin> gVhas('domain')。groupBy {it.domain} {it.id} .cap 

==> {google.com = [4],yahoo.com = [16,24 ,20]}

我能够对顶点进行分组,但我只需要那些域(顶点)它不止一次存在。

在上面的例子中,我只需要返回 ==>> {yahoo.com = [16,24,20]




















$ b考虑使用 groupCount 而不是 groupBy

解决方案以保存在收集列表中计算ID的步骤:

  gVhas('domain')。groupCount(it.domain } .cap.next()。findAll {it.value> 1} 

我猜这样比较便宜以及更大的遍历,因为你只是维护一个计数器而不是标识符列表。


I am using TITAN 0.4, and gremlin for traversals. My requirement is to identify duplicate vertices in graph, and to merge those. There are > 15 M vertices in graph.

gremlin> g.V.has('domain').groupBy{it.domain}{it.id}.cap

==>{google.com=[4], yahoo.com=[16, 24, 20]}

I am able to group the vertices, but I need only those domains(vertices) which exists more than once.

In the above example, I need to return only ==>{yahoo.com=[16, 24, 20]} The key "domain" is indexed, if that makes any difference.

Please help me here

解决方案

Consider use of groupCount rather than groupBy to save a step of counting up ids in your collected list:

g.V.has('domain').groupCount(it.domain}.cap.next().findAll{it.value>1}

I suppose this is cheaper as well on a larger traversal as you are just maintaining a counter rather than lists of identifiers.

这篇关于Gremlin:GroupBy顶点,计数> 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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