Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

t-digest module for Redis

License

NotificationsYou must be signed in to change notification settings

usmanm/redis-tdigest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

This is a Redis module for thet-digest data structure which can be used for accurate online accumulation of rank-based statistics such as quantiles and cumulative distribution at a point. The implementation is based on theMerging Digest implementation by the author.

Building & Loading

Before going ahead, make sure that the Redis server you're using has support forRedis modules.

First, you'll have to build the Redis t-digest module from source.

make

This should generate a shared library calledtdigest.so in the root folder. You can now load it into Redis by using the followingredis.conf configuration directive:

loadmodule /path/to/tdigest.so

Alternatively, you can load it on an already running Redis server by issuing the following commands:

MODULE LOAD /path/to/tdigest.so

API

TDIGEST.NEW key [compression]

Initializes akey to an empty t-digest structure with thecompression provided or with the default compression of400.

Reply:"OK"

TDIGEST.ADD key value count [value count ...]

Adds avalue with the specifiedcount. Ifkey is missing, an empty t-digest structure is initialized with a default compression of400. Returns the sum of counts for all values added.

Reply:long long

TDIGEST.MERGE destkey sourcekey [sourcekey ...]

Merges one or moresourcekey intodestkey. Ifdestkey is missing, an empty t-digest structure is initialized with a default compression of400.

Reply:"OK"

TDIGEST.CDF key value [value ...]

Returns the cumulative distribution for all provided values.value must be a double. The cumulative distribution returned for all values is between0..1.

Reply:double array ornil if key missing

TDIGEST.QUANTILE key quantile [quantile ...]

Returns the estimate values at all provided quantiles.quantile must be adouble between0..1.

Reply:double array ornil if key missing

TDIGEST.DEBUG key

Prints debug information about the t-digest.

Reply: bulk strings array

The reply is of the form:

1) TDIGEST (<compression>, <num_centroids>, <memory size>)2)   CENTROID (<mean>, <weight>)3)   CENTROID (<mean>, <weight>)4)   CENTROID (<mean>, <weight>)5)   ...

Centroids are printed in sorted order with respect to their mean.

Testing

The integration tests require a running Redis server so you must haveredis-server on yourPATH or pass its location in an environment variable calledREDIS_SERVER. Tests are written in Python and use thepytest unit testing library.

make test

Contributing

Bug reports, feature and pull requests are welcome! Please add tests for any non-trivial changes you submit.


[8]ページ先頭

©2009-2025 Movatter.jp