diff options
| author | levlam <levlam@telegram.org> | 2023-02-12 03:18:22 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2023-02-12 03:18:22 +0300 |
| commit | af27ba7c32b6c74e403120e75223735f93261384 (patch) | |
| tree | cf674d9e1e1875fe0fdbde1da9b4f45ad3ac2f28 /tddb | |
| parent | 896de65c3e4bb51f5cffd854c17fe92a2987247e (diff) | |
Return 0 from erase_batch for empty event list.
Diffstat (limited to 'tddb')
| -rw-r--r-- | tddb/td/db/binlog/Binlog.h | 5 | ||||
| -rw-r--r-- | tddb/td/db/binlog/BinlogInterface.h | 9 | ||||
| -rw-r--r-- | tddb/td/db/binlog/ConcurrentBinlog.cpp | 14 | ||||
| -rw-r--r-- | tddb/td/db/binlog/ConcurrentBinlog.h | 3 |
4 files changed, 22 insertions, 9 deletions
diff --git a/tddb/td/db/binlog/Binlog.h b/tddb/td/db/binlog/Binlog.h index 762a4cfcc..8cae93f18 100644 --- a/tddb/td/db/binlog/Binlog.h +++ b/tddb/td/db/binlog/Binlog.h @@ -93,7 +93,10 @@ class Binlog { return seq_no; } - uint64 erase_batch(std::vector<uint64> event_ids) { + uint64 erase_batch(vector<uint64> event_ids) { + if (event_ids.empty()) { + return 0; + } auto seq_no = next_event_id(0); for (auto event_id : event_ids) { erase(event_id); diff --git a/tddb/td/db/binlog/BinlogInterface.h b/tddb/td/db/binlog/BinlogInterface.h index f27e351bd..d46297f94 100644 --- a/tddb/td/db/binlog/BinlogInterface.h +++ b/tddb/td/db/binlog/BinlogInterface.h @@ -63,10 +63,13 @@ class BinlogInterface { return seq_no; } - virtual uint64 erase_batch(std::vector<uint64> event_ids) { + virtual uint64 erase_batch(vector<uint64> event_ids) { + if (event_ids.empty()) { + return 0; + } uint64 seq_no = next_event_id(0); - for (auto id : event_ids) { - erase(id); + for (auto event_id : event_ids) { + erase(event_id); } return seq_no; } diff --git a/tddb/td/db/binlog/ConcurrentBinlog.cpp b/tddb/td/db/binlog/ConcurrentBinlog.cpp index cd6a95707..437a4bbbf 100644 --- a/tddb/td/db/binlog/ConcurrentBinlog.cpp +++ b/tddb/td/db/binlog/ConcurrentBinlog.cpp @@ -7,6 +7,7 @@ #include "td/db/binlog/ConcurrentBinlog.h" #include "td/utils/logging.h" +#include "td/utils/misc.h" #include "td/utils/OrderedEventsProcessor.h" #include "td/utils/SliceBuilder.h" #include "td/utils/Time.h" @@ -42,8 +43,9 @@ class BinlogActor final : public Actor { void erase_batch(uint64 seq_no, std::vector<uint64> event_ids) { for (auto event_id : event_ids) { - auto event = BinlogEvent::create_raw(event_id, BinlogEvent::ServiceTypes::Empty, BinlogEvent::Flags::Rewrite, EmptyStorer()); - add_raw_event(seq_no, std::move(event), {}, {}); + auto event = BinlogEvent::create_raw(event_id, BinlogEvent::ServiceTypes::Empty, BinlogEvent::Flags::Rewrite, + EmptyStorer()); + add_raw_event(seq_no, std::move(event), Promise<Unit>(), BinlogDebugInfo{__FILE__, __LINE__}); seq_no++; } } @@ -213,10 +215,14 @@ void ConcurrentBinlog::change_key(DbKey db_key, Promise<> promise) { send_closure(binlog_actor_, &detail::BinlogActor::change_key, std::move(db_key), std::move(promise)); } -uint64 ConcurrentBinlog::erase_batch(std::vector<uint64> event_ids) { - auto shift = td::narrow_cast<int32>(event_ids.size()); +uint64 ConcurrentBinlog::erase_batch(vector<uint64> event_ids) { + auto shift = narrow_cast<int32>(event_ids.size()); + if (shift == 0) { + return 0; + } auto seq_no = next_event_id(shift); send_closure(binlog_actor_, &detail::BinlogActor::erase_batch, seq_no, std::move(event_ids)); return seq_no; } + } // namespace td diff --git a/tddb/td/db/binlog/ConcurrentBinlog.h b/tddb/td/db/binlog/ConcurrentBinlog.h index 33e91b11b..cdac7d0dd 100644 --- a/tddb/td/db/binlog/ConcurrentBinlog.h +++ b/tddb/td/db/binlog/ConcurrentBinlog.h @@ -55,7 +55,8 @@ class ConcurrentBinlog final : public BinlogInterface { CSlice get_path() const { return path_; } - uint64 erase_batch(std::vector<uint64> event_ids) final; + + uint64 erase_batch(vector<uint64> event_ids) final; private: void init_impl(unique_ptr<Binlog> binlog, int scheduler_id); |
