SharonIV0x86 commented on code in PR #2826:
URL: https://github.com/apache/kvrocks/pull/2826#discussion_r1997559172
##########
src/commands/cmd_tdigest.cc:
##########
@@ -202,7 +201,36 @@ class CommandTDigestMinMax : public Commander {
std::string key_name_;
bool is_min_;
};
+class CommandTDigestReset : public Commander {
+ Status Parse(const std::vector<std::string> &args) override {
+ key_name_ = args[1];
+ return Status::OK();
+ }
+ Status Execute(engine::Context &ctx, Server *srv, Connection *conn,
std::string *output) override {
+ TDigest tdigest(srv->storage, conn->GetNamespace());
+ TDigestMetadata metadata;
+ auto s = tdigest.GetMetaData(ctx, key_name_, &metadata);
+ if (!s.ok()) {
+ if (s.IsNotFound()) {
+ return {Status::RedisExecErr, errKeyNotFound};
+ }
+ return {Status::RedisExecErr, s.ToString()};
+ }
+ if (metadata.total_observations == 0) {
Review Comment:
Ill check with redis-stack once i set it up.
Assuming the output you attached is from redis-stack.
In the current implementation, when performing a reset on a empty tdigest
"nan" is returned, i guess we can replace this with a OK response just like
redis-stack.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]