TDIGEST.MERGE
TDIGEST.MERGE destination-key numkeys source-key [source-key ...] [COMPRESSION compression] [OVERRIDE]
- Available in:
- Redis Open Source / Bloom 2.4.0
- Time complexity:
- O(N*K), where N is the number of centroids and K being the number of input sketches
- ACL categories:
-
@tdigest
,@write
,@slow
,
Merges multiple t-digest sketches into a single sketch.
Required arguments
destination-key
is the key name for a t-digest sketch to merge observation values to.
If destination-key
does not exist, a new sketch is created.
If destination-key
is an existing sketch, its values are merged with the values of the source keys. To override the destination key contents use OVERRIDE
.
numkeys
the number of sketches from which to merge observation values (one or more).
source-key
Each source-key
is a key name for a t-digest sketch from which to merge observation values.
Optional arguments
COMPRESSION compression
is a controllable tradeoff between accuracy and memory consumption. 100 is a common value for normal uses and also the default if not specified. 1000 is more accurate. For more information on scaling of accuracy versus the compression value see The t-digest: Efficient estimates of distributions.
When COMPRESSION
is not specified:
- If
destination-key
does not exist or ifOVERRIDE
is specified, the compression is set to the maximum value among all source sketches. - If
destination-key
already exists andOVERRIDE
is not specified, its compression is not changed.
OVERRIDE
If destination-key
already exists and OVERRIDE
is specified, the key is overwritten.
Examples
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"
Return information
One of the following:
- Simple string reply
OK
if successful. - Simple error reply in the following cases: incorrect key type, incorrect keyword, or incorrect number of arguments.