【问题标题】:Gremlin traversal queries on spark graph火花图上的 Gremlin 遍历查询
【发布时间】:2020-09-17 00:44:42
【问题描述】:

我使用 Apache Spark Graphx 框架从 s3 构建了一个属性图(6000 万个节点,4000 万条边)。 我想在这个图上触发遍历查询。

我的查询是这样的:-

g.V().has("name","xyz").out('parent').out().has('name','abc')
g.V().has('proc_name','serv.exe').out('file_create').
has('file_path',containing('Tsk04.txt')).in().in('parent').values('proc_name')
g.V().has('md5','935ca12348040410e0b2a8215180474e').values('files')

大部分查询的格式为g.V().out().out().out()

在 neo4j、titan、aws neptune 等图形数据库上很容易实现此类查询,因为它们支持 gremlin。

我们可以以这种方式遍历火花图吗? 我尝试了 spark pregel-api,但与 gremlin 相比它有点复杂。

我正在寻找 spark graph 的原因是因为上述 graphdbs 的云解决方案成本很高。

【问题讨论】:

标签: apache-spark gremlin graph-databases spark-graphx


【解决方案1】:

Spark GraphFrames 库对您来说应该是最方便的。它提供了类似 neo4j-cypher 的遍历描述,并使用 Spark DataFrames api 进行过滤
https://graphframes.github.io/graphframes/docs/_site/user-guide.html#motif-finding 这是一个例子:

val g2: GraphFrame = GraphFrame.fromGraphX(gx) // you can start with just V and E DataFrames here
val motifs: GraphFrame = g.find("(a)-[e]->(b); (b)-[e2]->(c)")
motifs.filter("a.name = 'xyz'  and e.label = 'parent' and c.name = 'abc'").show()

TinkerPop 它本身具有 spark 支持,因此您可以从 gremlin 控制台发出 spark OLAP 查询 https://tinkerpop.apache.org/docs/current/reference/#sparkgraphcomputer

或者有一些封闭源代码的解决方案。 Datastax 企业数据库对 Spark 有很好的 Gremlin 支持:https://www.datastax.com/blog/2017/05/introducing-dse-graph-frames 我是它的前作者

【讨论】:

  • 非常感谢@Artem Aliev 探索了 GraphFrame,感觉我可以使用它解决大部分用例。
猜你喜欢
  • 1970-01-01
  • 2021-10-26
  • 1970-01-01
  • 2021-04-27
  • 2016-08-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多