TDIGEST.MERGE

Syntax
TDIGEST.MERGE destination-key numkeys source-key [source-key ...]
  [COMPRESSION compression] [OVERRIDE]
Available in:
Redis Stack / Bloom 2.4.0
Time complexity:
O(N*K), where N is the number of centroids and K being the number of input sketches

将多个t-digest草图合并为一个单一的草图。

必需的参数

destination-key

是用于合并观测值的t-digest草图的关键名称。

如果 destination-key 不存在 - 将创建一个新的草图。

如果destination-key是一个现有的草图,它的值将与源键的值合并。要覆盖目标键的内容,请使用OVERRIDE

numkeys Number of sketches to merge observation values from (1 or more).
source-key each is a key name for a t-digest sketch to merge observation values from.

可选参数

COMPRESSION compression

是在准确性和内存消耗之间的可控权衡。100是正常使用的常见值。1000更准确。如果没有传递值,默认情况下压缩将为100。有关准确性与压缩参数缩放的更多信息,请参见The t-digest: Efficient estimates of distributions

当未指定COMPRESSION时:

  • 如果destination-key不存在或指定了OVERRIDE,则压缩设置为所有源草图中的最大值。
  • 如果 destination-key 已经存在且未指定 OVERRIDE,则其压缩方式不会改变。
OVERRIDE When specified, if `destination-key` already exists, it is overwritten.

返回值

成功时返回OK,否则返回错误。

示例

redis> TDIGEST.CREATE s1
OK
redis> TDIGEST.CREATE s2
OK
redis> TDIGEST.ADD s1 10.0 20.0
OK
redis> TDIGEST.ADD s2 30.0 40.0
OK
redis> TDIGEST.MERGE sM 2 s1 s2
OK
redis> TDIGEST.BYRANK sM 0 1 2 3 4
1) "10"
2) "20"
3) "30"
4) "40"
5) "inf"

RATE THIS PAGE
Back to top ↑