0

我对 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,而不是使用计数。

4

1 回答 1

1

简单的时髦:

l = [" 3"," 3"," 3"," 3"," 3"," 3"," 3"," 3"," 3"]
s = 0; l.each{s+=it.toInteger()}
s
==>27
于 2014-12-09T16:39:17.280 回答