Skip to content

Add LogData WriteBatch::Handler implementation #13450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions db/c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2282,6 +2282,15 @@ class H : public WriteBatch::Handler {
}
};

class HL : public WriteBatch::Handler {
public:
void* state_;
void (*log_data_)(void*, const char* d, size_t dlen);
void LogData(const Slice& data) override {
(*log_data_)(state_, data.data(), data.size());
}
};

class HCF : public WriteBatch::Handler {
public:
void* state_;
Expand Down Expand Up @@ -2320,6 +2329,16 @@ void rocksdb_writebatch_iterate(rocksdb_writebatch_t* b, void* state,
b->rep.Iterate(&handler);
}

void rocksdb_writebatch_iterate_log(rocksdb_writebatch_t* b, void* state,
void (*log_data)(void*, const char* d,
size_t dlen)
) {
HL handler;
handler.state_ = state;
handler.log_data_ = log_data;
b->rep.Iterate(&handler);
}

void rocksdb_writebatch_iterate_cf(
rocksdb_writebatch_t* b, void* state,
void (*put_cf)(void*, uint32_t cfid, const char* k, size_t klen,
Expand Down
3 changes: 3 additions & 0 deletions include/rocksdb/c.h
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,9 @@ extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_iterate(
rocksdb_writebatch_t*, void* state,
void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen),
void (*deleted)(void*, const char* k, size_t klen));
extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_iterate_log(
rocksdb_writebatch_t*, void* state,
void (*log_data)(void*, const char* d, size_t dlen));
extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_iterate_cf(
rocksdb_writebatch_t*, void* state,
void (*put_cf)(void*, uint32_t cfid, const char* k, size_t klen,
Expand Down