git-hulk commented on code in PR #2845:
URL: https://github.com/apache/kvrocks/pull/2845#discussion_r2019712441


##########
src/commands/cmd_server.cc:
##########
@@ -1370,6 +1370,51 @@ class CommandPollUpdates : public Commander {
   Format format_ = Format::Raw;
 };
 
+class CommandSST : public Commander {
+ public:
+  Status Parse(const std::vector<std::string> &args) override {
+    if (args.size() < 3) {
+      return {Status::RedisParseErr, "Invalid number of arguments"};

Review Comment:
   ```suggestion
         return {Status::RedisParseErr, errWrongNumOfArguments};
   ```



##########
src/commands/cmd_server.cc:
##########
@@ -1370,6 +1370,51 @@ class CommandPollUpdates : public Commander {
   Format format_ = Format::Raw;
 };
 
+class CommandSST : public Commander {
+ public:
+  Status Parse(const std::vector<std::string> &args) override {
+    if (args.size() < 3) {
+      return {Status::RedisParseErr, "Invalid number of arguments"};
+    }
+    std::string cmd = util::ToLower(args[1]);

Review Comment:
   Could use `Commandparser` here.



##########
src/commands/cmd_server.cc:
##########
@@ -1410,5 +1455,6 @@ REDIS_REGISTER_COMMANDS(Server, 
MakeCmdAttr<CommandAuth>("auth", 2, "read-only o
                         MakeCmdAttr<CommandReset>("reset", 1, "ok-loading 
bypass-multi no-script", NO_KEY),
                         MakeCmdAttr<CommandApplyBatch>("applybatch", -2, 
"write no-multi", NO_KEY),
                         MakeCmdAttr<CommandDump>("dump", 2, "read-only", 1, 1, 
1),
-                        MakeCmdAttr<CommandPollUpdates>("pollupdates", -2, 
"read-only admin", NO_KEY), )
+                        MakeCmdAttr<CommandPollUpdates>("pollupdates", -2, 
"read-only admin", NO_KEY),
+                        MakeCmdAttr<CommandSST>("sst", -3, "write admin", 1, 
1, 1), )

Review Comment:
   Need to add the `exclusive` flag for this command.



##########
src/storage/storage.cc:
##########
@@ -769,6 +775,65 @@ rocksdb::Status Storage::FlushScripts(engine::Context 
&ctx, const rocksdb::Write
   return Write(ctx, options, batch->GetWriteBatch());
 }
 
+rocksdb::Status Storage::IngestSST(const std::string &sst_dir, int* 
files_loaded) {
+  std::vector<std::string> sst_files;
+  DIR *dir = opendir(sst_dir.c_str());
+  if (!dir) {
+    return rocksdb::Status::IOError("Failed to open directory " + sst_dir);
+  }
+
+  struct dirent *entry;
+  while ((entry = readdir(dir)) != nullptr) {
+    std::string filename = entry->d_name;
+    if (filename.length() >= 4 && filename.substr(filename.length() - 4) == 
".sst") {
+      sst_files.push_back(sst_dir + "/" + filename);
+    }
+  }
+  closedir(dir);
+
+  if (sst_files.empty()) {
+    LOG(WARNING) << "No SST files found in " << sst_dir;
+    return rocksdb::Status::OK();
+  }
+
+  std::vector<std::string> default_files;
+  std::vector<std::string> metadata_files;
+
+  // Sort files into appropriate vectors based on filename
+  for (const auto &file : sst_files) {
+    if (file.find("metadata") != std::string::npos) {
+      metadata_files.push_back(file);
+    } else {
+      default_files.push_back(file);
+    }
+  }

Review Comment:
   @ltagliamonte-dd The SST file writer will record the column family if it's 
assigned, so I think we could find the column family through the SST table 
properties when loading.
   
   Please refer to 
https://github.com/facebook/rocksdb/blob/743a02d6f68811bed8c5f3ce5d7e6d9b6bc18783/table/sst_file_writer.cc#L396



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