gremlin - Gremlin:使用时间戳属性过滤重复边
问题描述
我有不同时间戳的重复边,需要获取最新的时间戳边,我试图通过下面的查询来获取。我无法使用.max()
,因为它适用于数字。有没有其他选择?
g.V().has('streamPath','/local/Prod/SupportBI/Prod/Staging/Integration/Chat/MSaaSChatCompleted.ss').as('ParentStream').outE('generate').order().by('timestamp', decr).values('timestamp')
样本输出
[
"2018-07-10T20:18:57",
"2018-07-10T20:18:57",
"2018-07-10T20:16:39",
"2018-07-10T20:16:39",
"2018-07-10T20:07:51",
"2018-07-10T16:18:56",
我的实际查询:
g.V().has('streamPath','/Chat/Completed.ss').as('ParentStream').outE('generate').as('Edges').map(select('Edges').inV()).as ('NextStream').select('ParentStream', 'NextStream','Edges').simplePath()
我得到了重复的边缘(时间戳、jobid、id 不同,属性的重置相同)。需要采用具有最新时间戳的最近边缘。
解决方案
如果你有这个:
g.V().has('streamPath','/local/Prod/SupportBI/Prod/Staging/Integration/Chat/MSaaSChatCompleted.ss').as('ParentStream').
outE('generate').
order().
by('timestamp', decr).
values('timestamp')
您不能添加limit(1)
到第一个,因为您首先订购了最近的时间戳吗?
附带说明一下,在 TinkerPop 3.4.0(在此答案时未发布)中,您可以使用max()
任何Comparable
:
gremlin> g.V().values('name').max()
==>vadas
推荐阅读
- python - 如何在 Visual Studio Code 中获取 anaconda(选择 python 解释器)
- machine-learning - 如何在 Keras 中将嵌入与可变长度输入连接起来?
- c - fscanf 没有读取随机值,对吗?
- c++ - 我正在尝试在 Visual Studio 上创建自己的库/源函数
- python - 如何为打开的 jupyter notebook 切换环境
- java - 当我按下录制按钮时,android 应用程序在 6 秒后崩溃
- javascript - JS find() 不适用于对象数组
- powershell - 如何将两个变量导出到通过 PowerShell 加入的相同 CSV?
- python - 以字符串形式读取 pandas 中的所有列
- ssh - ssh 代理发现规则中的 Zabbix 公钥授权