LindaSummer commented on code in PR #2826:
URL: https://github.com/apache/kvrocks/pull/2826#discussion_r1997547400


##########
src/types/redis_tdigest.cc:
##########
@@ -273,6 +271,11 @@ rocksdb::Status TDigest::Reset(engine::Context& ctx, const 
Slice& digest_name) {
     return status;
   }
 
+  if (!status.ok()) return status;
+  auto start_key = internalSegmentGuardPrefixKey(metadata, ns_key, 
SegmentType::kBuffer);
+  auto guard_key = internalSegmentGuardPrefixKey(metadata, ns_key, 
SegmentType::kGuardFlag);
+  
+  status = batch->DeleteRange(cf_handle_, start_key, guard_key);

Review Comment:
   ```suggestion
     status = batch->DeleteRange(cf_handle_, start_key, guard_key);
     if (!status.ok()) {
       return status;
     }
   ```



##########
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:
   Hi @SharonIV0x86 ,
   
   I have tested this case on redis-stack docker.
   It seems to respond with `OK`.
   ```
   127.0.0.1:6389> tdigest.create hahah compression 1000
   OK
   127.0.0.1:6389> tdigest.reset hahah
   OK
   ```
   
   Could you help us double-check this behavior for this `nan` response on 
redis-stack and add a go test case?
   
   
   Best Regards,
   Edward



-- 
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]

Reply via email to