mapleFU commented on code in PR #2332:
URL: https://github.com/apache/kvrocks/pull/2332#discussion_r1685749818
##########
src/storage/storage.cc:
##########
@@ -530,6 +531,7 @@ Status Storage::RestoreFromCheckpoint() {
}
bool Storage::IsEmptyDB() {
+ // TODO ctx?
Review Comment:
Hmm I think `Storage` itself shouldn't require on `Ctx`
##########
src/storage/storage.cc:
##########
@@ -660,46 +676,56 @@ void Storage::MultiGet(const rocksdb::ReadOptions
&options, rocksdb::ColumnFamil
}
}
-rocksdb::Status Storage::Write(const rocksdb::WriteOptions &options,
rocksdb::WriteBatch *updates) {
+rocksdb::Status Storage::Write(engine::Context &ctx, const
rocksdb::WriteOptions &options,
+ rocksdb::WriteBatch *updates) {
if (is_txn_mode_) {
// The batch won't be flushed until the transaction was committed or
rollback
return rocksdb::Status::OK();
}
- return writeToDB(options, updates);
+ return writeToDB(ctx, options, updates);
}
-rocksdb::Status Storage::writeToDB(const rocksdb::WriteOptions &options,
rocksdb::WriteBatch *updates) {
+rocksdb::Status Storage::writeToDB(engine::Context &ctx, const
rocksdb::WriteOptions &options,
+ rocksdb::WriteBatch *updates) {
// Put replication id logdata at the end of write batch
if (replid_.length() == kReplIdLength) {
updates->PutLogData(ServerLogData(kReplIdLog, replid_).Encode());
}
+ if (ctx.batch == nullptr) {
+ ctx.batch = std::make_unique<rocksdb::WriteBatchWithIndex>();
+ }
+ WriteBatchIndexer handle(this, ctx.batch.get());
+ auto s = updates->Iterate(&handle);
Review Comment:
👍
##########
src/storage/scripting.h:
##########
@@ -26,6 +26,7 @@
#include "lua.hpp"
#include "server/redis_connection.h"
#include "status.h"
+#include "storage.h"
Review Comment:
Maybe not an issue but maybe we can use forward declaration for 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]