ltagliamonte-dd commented on code in PR #2845:
URL: https://github.com/apache/kvrocks/pull/2845#discussion_r2029857403


##########
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:
   @git-hulk I looked at your proposal about inserting the CF name in the 
sstfile and It can't be done atm.
   although the SstFileWriter supports the ColumnFamilyHandle parameter, the 
only 2 exposed method do not:
   
https://github.com/facebook/rocksdb/blob/v10.0.1/include/rocksdb/c.h#L2301-L2307
   So until this is supported upstream (I can sponsor that effort, and improve 
this code in a second PR) the only way to identify CF seems to use the file 
name unfortunately. 



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