From d8a11c7fa6a0ac936b740478bb639f19790f1ac0 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 10 Jun 2020 21:48:11 +0300 Subject: [PATCH] Add Binlog::add/rewrite/erase. GitOrigin-RevId: 99b0234d5d700081834ba00c79fcc3da264344be --- tddb/td/db/binlog/Binlog.h | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tddb/td/db/binlog/Binlog.h b/tddb/td/db/binlog/Binlog.h index 5a6221e378a4..548d1d754308 100644 --- a/tddb/td/db/binlog/Binlog.h +++ b/tddb/td/db/binlog/Binlog.h @@ -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 @@ -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));