PragmaTwice commented on code in PR #3313:
URL: https://github.com/apache/kvrocks/pull/3313#discussion_r2650074221


##########
src/commands/cmd_string.cc:
##########
@@ -721,10 +722,39 @@ class CommandLCS : public Commander {
   int64_t min_match_len_ = 0;
 };
 
+class CommandDigest : public Commander {
+ public:
+  Status Execute(engine::Context &ctx, Server *srv, Connection *conn, 
std::string *output) override {
+    redis::String string_db(srv->storage, conn->GetNamespace());
+    std::string digest;
+    auto s = string_db.Digest(ctx, args_[1], &digest);
+    if (s.IsInvalidArgument()) {
+      Config *config = srv->GetConfig();
+      uint32_t max_btos_size = 
static_cast<uint32_t>(config->max_bitmap_to_string_mb) * MiB;
+      redis::Bitmap bitmap_db(srv->storage, conn->GetNamespace());
+      std::string value;
+      s = bitmap_db.GetString(ctx, args_[1], max_btos_size, &value);
+      if (s.ok()) {
+        digest = util::ComputeXXH3Hash(value);
+      }
+    }

Review Comment:
   ditto.



##########
src/commands/cmd_string.cc:
##########
@@ -18,12 +18,13 @@
  *
  */
 
+#include "commander.h"
 #include <cstdint>
 #include <optional>
 #include <string>
-
-#include "commander.h"
+#include <fmt/format.h>
 #include "commands/command_parser.h"
+#include "common/string_util.h"

Review Comment:
   and this.



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