ltagliamonte-dd commented on code in PR #2845:
URL: https://github.com/apache/kvrocks/pull/2845#discussion_r2012591391
##########
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:
@PragmaTwice I see the following CF defined:
```
enum class ColumnFamilyID : uint32_t {
PrimarySubkey = 0,
Metadata,
SecondarySubkey,
PubSub,
Propagate,
Stream,
Search,
};
```
from a quick look at this we could hardcode `default` and search in the
folder for all the files that matches those CF? honestly i don't think all CF
make sense, eager to hear your opinion.
--
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]