gpt4 book ai didi

gremlin - 有没有办法在计算特征之前存储过滤的边缘

转载 作者:行者123 更新时间:2023-12-04 09:43:39 26 4
gpt4 key购买 nike

对于给定的顶点,我想计算多个聚合特征,这些特征彼此不明显,我可能会这样做。

g.V(81968)
.project('P1', 'P2', 'P3')
.by(__.bothE().has('dt_int', lt(999999999999)).values('orig_amt').mean())
.by(__.bothE().has('dt_int', lt(999999999999)).values('currency').dedup().count())
.by(__.bothE().has('dt_int', lt(999999999999)).values('weight').mean())

这个查询的明显问题是我正在计算 __.bothE().has('trxn_dt', lt(999999999999))每次我想创建一个新的聚合特征时(即 P1P2P3 )。当我尝试为具有大量边的顶点计算这组特征时,这一点变得很清楚。

有没有办法存储过滤后的边集,然后选择它供以后使用?类似于这个伪查询:
g.V(81968)
.hold(__.bothE().has('dt_int', lt(999999999999))).as('edges')
.project('P1', 'P2', 'P3')
.by(select('edges').values('orig_amt').mean())
.by(select('edges').values('currency').dedup().count())
.by(select('edges').values('weight').mean())

这个问题可以追溯到我之前问过的一个问题 ( here ),但我正在寻找一种更通用的方法,并且我正在努力使其适应一组通用功能。

最佳答案

你建议你“持有()”结果,而 Gremlin 有 aggregate()store()对于此类事情,如果您需要 List , 只是 fold()您的结果,然后 project()那个单例List因为你需要:

g.V(81968).bothE().has('dt_int', lt(999999999999)).
fold().
project('P1', 'P2', 'P3').
by(unfold().values('orig_amt').mean()).
by(unfold().values('currency').dedup().count()).
by(unfold().values('weight').mean())

通过这种方式,您不需要副作用或路径跟踪。

关于gremlin - 有没有办法在计算特征之前存储过滤的边缘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62221857/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com