【问题标题】:How to summarize property values in Gremlin?如何在 Gremlin 中总结属性值?
【发布时间】:2015-02-07 14:46:46
【问题描述】:

我对 Gremlin 还很陌生,现在花了几个小时试图弄清楚如何计算我所有顶点中给定属性的值。

这个

g.V('containerName','MyContainer').outE.inV.'(0)Probability'

给我:

 {"results":[" 3"," 3"," 3"," 3"," 3"," 3"," 3"," 3"," 3"],"success":true,"version":"2.4.0","queryTime":15.894908}

所以我想弄清楚的是:

  1. 如何将列表中的字符串转换为整数?我试过了……

    g.V('containerName','CvsRisk').outE.inV.'(0)Probability'.toInteger()
    

    ...,但它不起作用。

  2. 如何汇总列表中的所有值,即3+3+...+3,不使用count。

【问题讨论】:

  • 你的意思是“总结”和“总结”吗?

标签: groovy titan gremlin rexster


【解决方案1】:

简单的常规:

l = [" 3"," 3"," 3"," 3"," 3"," 3"," 3"," 3"," 3"]
s = 0; l.each{s+=it.toInteger()}
s
==>27

【讨论】:

  • 更简单的 groovy l*.toInteger()l*.toInteger().sum()
  • 再次感谢 Faber :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-08-08
  • 1970-01-01
  • 2016-01-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-06
相关资源
最近更新 更多