TDIGEST.REVRANK

语法
TDIGEST.REVRANK key value [value ...]
可用版本
Redis 开源版 / Bloom 2.4.0
时间复杂度
O(N),其中 N 是指定值的数量。
ACL 类别
@tdigest, @read,

对于每个输入值(浮点数),返回该值的估计逆向排名(草图中的观察值中大于该值的数量 + 等于该值的观察值数量的一半)。

可以在一次调用中检索多个逆向排名。

必需参数

key现有 t-digest 草图的键名。
value需要估计逆向排名的输入值。

返回值

Array reply - 包含 revrank_1, revrank_2, ..., revrank_V 的整数数组

  • -1 - 当 value 大于最大观察值时。
  • 观察值数量 - 当 value 小于最小观察值时。
  • 否则:估计的数量(大于 value 的观察值 + 等于 value 的观察值的一半)。

0 是最大观察值的逆向排名。

n-1 是最小观察值的逆向排名;n 表示添加到草图中的观察值数量。

如果草图为空,则所有值均为 -2。

示例

redis> TDIGEST.CREATE s COMPRESSION 1000
OK
redis> TDIGEST.ADD s 10 20 30 40 50 60
OK
redis> TDIGEST.RANK s 0 10 20 30 40 50 60 70
1) (integer) -1
2) (integer) 0
3) (integer) 1
4) (integer) 2
5) (integer) 3
6) (integer) 4
7) (integer) 5
8) (integer) 6
redis> TDIGEST.REVRANK s 0 10 20 30 40 50 60 70
1) (integer) 6
2) (integer) 5
3) (integer) 4
4) (integer) 3
5) (integer) 2
6) (integer) 1
7) (integer) 0
8) (integer) -1
redis> TDIGEST.CREATE s COMPRESSION 1000
OK
redis> TDIGEST.ADD s 10 10 10 10 20 20
OK
redis> TDIGEST.RANK s 10 20
1) (integer) 2
2) (integer) 5
redis> TDIGEST.REVRANK s 10 20
1) (integer) 4
2) (integer) 1

评价本页面
回到顶部 ↑
© . This site is unofficial and not affiliated with Redis, Inc.