diff options
author | dvora-h <67596500+dvora-h@users.noreply.github.com> | 2022-08-02 15:56:49 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-02 15:56:49 +0300 |
commit | 9901c7963ff5c5f68ff7e651142c51c2d715c5eb (patch) | |
tree | 999f2006c1d37e1c74d82b27ab2929dc083b3a2f /redis | |
parent | 4ed8aba8441ae841e2c8e698b84ebda1da8208f9 (diff) | |
download | redis-py-9901c7963ff5c5f68ff7e651142c51c2d715c5eb.tar.gz |
Add support for `TDIGEST.QUANTILE` extensions (#2317)
* Add support for TDIGEST.QUANTILE extensions
* linters
* linters & utils
* Update test_bloom.py
Diffstat (limited to 'redis')
-rw-r--r-- | redis/commands/bf/__init__.py | 3 | ||||
-rw-r--r-- | redis/commands/bf/commands.py | 9 | ||||
-rw-r--r-- | redis/commands/bf/utils.py | 3 |
3 files changed, 10 insertions, 5 deletions
diff --git a/redis/commands/bf/__init__.py b/redis/commands/bf/__init__.py index d62d8a0..3169ba2 100644 --- a/redis/commands/bf/__init__.py +++ b/redis/commands/bf/__init__.py @@ -3,6 +3,7 @@ from redis.client import bool_ok from ..helpers import parse_to_list from .commands import * # noqa from .info import BFInfo, CFInfo, CMSInfo, TDigestInfo, TopKInfo +from .utils import parse_tdigest_quantile class AbstractBloom(object): @@ -166,7 +167,7 @@ class TDigestBloom(TDigestCommands, AbstractBloom): # TDIGEST_ADD: spaceHolder, # TDIGEST_MERGE: spaceHolder, TDIGEST_CDF: float, - TDIGEST_QUANTILE: float, + TDIGEST_QUANTILE: parse_tdigest_quantile, TDIGEST_MIN: float, TDIGEST_MAX: float, TDIGEST_INFO: TDigestInfo, diff --git a/redis/commands/bf/commands.py b/redis/commands/bf/commands.py index baf0130..7d36b93 100644 --- a/redis/commands/bf/commands.py +++ b/redis/commands/bf/commands.py @@ -393,13 +393,14 @@ class TDigestCommands: """ # noqa return self.execute_command(TDIGEST_MAX, key) - def quantile(self, key, quantile): + def quantile(self, key, quantile, *quantiles): """ - Return double value estimate of the cutoff such that a specified fraction of the data - added to this TDigest would be less than or equal to the cutoff. + Returns estimates of one or more cutoffs such that a specified fraction of the + observations added to this t-digest would be less than or equal to each of the + specified cutoffs. (Multiple quantiles can be returned with one call) For more information see `TDIGEST.QUANTILE <https://redis.io/commands/tdigest.quantile>`_. """ # noqa - return self.execute_command(TDIGEST_QUANTILE, key, quantile) + return self.execute_command(TDIGEST_QUANTILE, key, quantile, *quantiles) def cdf(self, key, value): """ diff --git a/redis/commands/bf/utils.py b/redis/commands/bf/utils.py new file mode 100644 index 0000000..21dcfa7 --- /dev/null +++ b/redis/commands/bf/utils.py @@ -0,0 +1,3 @@ +def parse_tdigest_quantile(response): + """Parse TDIGEST.QUANTILE response.""" + return [float(x) for x in response] |