gremlin - 如何在 Apache TinkerPop Gremlin 中使用分页?
问题描述
怎么pagination
用apache tinker pop gremlin
?试图同时获得count
和vertex properties
g.V().hasLabel('person').fold().as('persons','count').
select('persons','count').
by(range(local, 2, 4)).
by(count(local))
输出:-
{'persons': [v[2e6279e5-ad7c-48e3-9527-4972e55ecd24],
v[bb01581c-de6f-4c57-92f5-6fe090011279]], 'count': 36}
如何获得properties of vertex
而不仅仅是T.id
?
解决方案
添加另一个答案只是为了指出可能的性能优化。如果图中有很多人,那么具体化所有属性然后只选择几个属性可能会给查询引擎带来很多浪费的工作要做。在查询中尽可能晚地具体化结果通常会更好。这是对其他答案的小改写。
g.V().hasLabel('persons').fold().as('persons','count').
select('persons','count').
by(range(local, 2, 4).unfold().elementMap().fold()).
by(count(local))
当然,我假设您有一个更复杂的场景,因为显示的示例根本不需要fold
。您可以只使用一个union
步骤或其他聚合结果的东西。
g.V().hasLabel('person').
union(range(2,4).elementMap(),count()).
fold()
推荐阅读
- ios - 当我尝试使用 insertTimeRange 时,表达式类型不明确,没有更多上下文错误
- plot - Plotly Line Chart - 点连接顺序错误
- python - 如何使情节三元情节看起来像倒三角形?
- ios - xcode 12:无法打开文件“app name”,因为您无权查看它
- django - 当我在 Django 中运行服务器时,它没有运行为 127.0.0.0:8000 而不是这个,而是 127.0.0.0:8000/application
- html - 如何在 Angular 中组合函数
- python - Python - 需要帮助将src 存储在 CSV 中,从 CSV 列表下载图像
- mysql - 如何根据时间日期返回活动 mysql 5.7
- json - 使用 JQ 在 JSON 上加入匹配
- r - 如何在 R 2020 的一张图中绘制多个箱线图