Skip to content

Commit

Permalink
Add Binlog::add/rewrite/erase.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 99b0234d5d700081834ba00c79fcc3da264344be
  • Loading branch information
levlam committed Jun 10, 2020
1 parent 4c8571d commit d8a11c7
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions tddb/td/db/binlog/Binlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "td/utils/port/FileFd.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
#include "td/utils/StorerBase.h"
#include "td/utils/UInt.h"

#include <functional>
Expand Down Expand Up @@ -68,9 +69,25 @@ class Binlog {
return fd_.empty();
}

//void add_raw_event(BufferSlice &&raw_event) {
//add_event(BinlogEvent(std::move(raw_event)));
//}
uint64 add(int32 type, const Storer &storer) {
auto logevent_id = next_id();
add_raw_event(BinlogEvent::create_raw(logevent_id, type, 0, storer), {});
return logevent_id;
}

uint64 rewrite(uint64 logevent_id, int32 type, const Storer &storer) {
auto seq_no = next_id();
add_raw_event(BinlogEvent::create_raw(logevent_id, type, BinlogEvent::Flags::Rewrite, storer), {});
return seq_no;
}

uint64 erase(uint64 logevent_id) {
auto seq_no = next_id();
add_raw_event(BinlogEvent::create_raw(logevent_id, BinlogEvent::ServiceTypes::Empty, BinlogEvent::Flags::Rewrite,
EmptyStorer()),
{});
return seq_no;
}

void add_raw_event(BufferSlice &&raw_event, BinlogDebugInfo info) {
add_event(BinlogEvent(std::move(raw_event), info));
Expand Down

0 comments on commit d8a11c7

Please sign in to comment.