-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(tdigest): add tdigest algorithm and storage encoding implementations #2741
base: unstable
Are you sure you want to change the base?
Changes from all commits
3ca2216
94d89c6
10527f1
5b62c77
b8f568f
675c815
d26ffeb
a462b07
f9b24b9
9d54b3d
ac5d7dd
067766f
2e22834
1b6a18a
da69aa9
b3a6370
303a4aa
d80a98f
32dc695
ac2ea2d
d79074e
aa24799
f84f7d3
592da56
7648868
1cb7eb6
d6817d3
91c760a
5a98607
9d7230b
f7fe96e
c4f9554
af5480b
9441342
7f6d090
0a6ae83
c23f106
f0f2f3d
0e842bb
1cb9882
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
#include <atomic> | ||
#include <bitset> | ||
#include <initializer_list> | ||
#include <limits> | ||
#include <string> | ||
#include <vector> | ||
|
||
|
@@ -51,6 +52,7 @@ enum RedisType : uint8_t { | |
kRedisBloomFilter = 9, | ||
kRedisJson = 10, | ||
kRedisHyperLogLog = 11, | ||
kRedisTDigest = 12, | ||
}; | ||
|
||
struct RedisTypes { | ||
|
@@ -92,9 +94,9 @@ enum RedisCommand { | |
kRedisCmdLMove, | ||
}; | ||
|
||
const std::vector<std::string> RedisTypeNames = {"none", "string", "hash", "list", | ||
"set", "zset", "bitmap", "sortedint", | ||
"stream", "MBbloom--", "ReJSON-RL", "hyperloglog"}; | ||
const std::vector<std::string> RedisTypeNames = {"none", "string", "hash", "list", "set", | ||
"zset", "bitmap", "sortedint", "stream", "MBbloom--", | ||
"ReJSON-RL", "hyperloglog", "TDIS-TYPE"}; | ||
|
||
constexpr const char *kErrMsgWrongType = "WRONGTYPE Operation against a key holding the wrong kind of value"; | ||
constexpr const char *kErrMsgKeyExpired = "the key was expired"; | ||
|
@@ -337,3 +339,27 @@ class HyperLogLogMetadata : public Metadata { | |
|
||
EncodeType encode_type = EncodeType::DENSE; | ||
}; | ||
|
||
class TDigestMetadata : public Metadata { | ||
public: | ||
uint32_t compression; | ||
uint32_t capacity; | ||
uint64_t unmerged_nodes = 0; | ||
uint64_t merged_nodes = 0; | ||
uint64_t total_weight = 0; | ||
uint64_t merged_weight = 0; | ||
double minimum = std::numeric_limits<double>::max(); | ||
double maximum = std::numeric_limits<double>::lowest(); | ||
uint64_t total_observations = 0; | ||
uint64_t merge_times = 0; | ||
Comment on lines
+353
to
+354
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So statisitics like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @mapleFU , These two metrics are used in Best Regards, |
||
|
||
explicit TDigestMetadata(uint32_t compression, uint32_t capacity, bool generate_version = true) | ||
: Metadata(kRedisTDigest, generate_version), compression(compression), capacity(capacity) {} | ||
explicit TDigestMetadata(bool generate_version = true) : TDigestMetadata(0, 0, generate_version) {} | ||
void Encode(std::string *dst) const override; | ||
rocksdb::Status Decode(Slice *input) override; | ||
|
||
uint64_t TotalNodes() const { return merged_nodes + unmerged_nodes; } | ||
|
||
double Delta() const { return 1. / static_cast<double>(compression); } | ||
mapleFU marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have some validate function here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mapleFU ,
Do you mean for validation the compression property?
I have added a limitation for it as suggested.
Best Regards,
Edward