Fix logevent_id type.

GitOrigin-RevId: a609c2f25c1898defe031ce90c72957a031e3f65
This commit is contained in:
levlam 2020-06-11 16:52:39 +03:00
parent 22c9927314
commit 2a6eebec24
2 changed files with 13 additions and 13 deletions

View File

@ -359,7 +359,7 @@ TQueueBinlog<BinlogT>::TQueueBinlog() {
diff_ = Clocks::system() - Time::now(); diff_ = Clocks::system() - Time::now();
} }
template <class BinlogT> template <class BinlogT>
int64 TQueueBinlog<BinlogT>::push(QueueId queue_id, const RawEvent &event) { uint64 TQueueBinlog<BinlogT>::push(QueueId queue_id, const RawEvent &event) {
TQueueLogEvent log_event; TQueueLogEvent log_event;
log_event.queue_id = queue_id; log_event.queue_id = queue_id;
log_event.event_id = event.event_id.value(); log_event.event_id = event.event_id.value();
@ -375,7 +375,7 @@ int64 TQueueBinlog<BinlogT>::push(QueueId queue_id, const RawEvent &event) {
} }
template <class BinlogT> template <class BinlogT>
void TQueueBinlog<BinlogT>::pop(int64 logevent_id) { void TQueueBinlog<BinlogT>::pop(uint64 logevent_id) {
binlog_->erase(logevent_id); binlog_->erase(logevent_id);
} }
@ -399,13 +399,13 @@ Status TQueueBinlog<BinlogT>::replay(const BinlogEvent &binlog_event, TQueue &q)
template class TQueueBinlog<BinlogInterface>; template class TQueueBinlog<BinlogInterface>;
template class TQueueBinlog<Binlog>; template class TQueueBinlog<Binlog>;
int64 MemoryStorage::push(QueueId queue_id, const RawEvent &event) { uint64 MemoryStorage::push(QueueId queue_id, const RawEvent &event) {
auto logevent_id = event.logevent_id == 0 ? next_logevent_id_++ : event.logevent_id; auto logevent_id = event.logevent_id == 0 ? next_logevent_id_++ : event.logevent_id;
events_[logevent_id] = std::make_pair(queue_id, event); events_[logevent_id] = std::make_pair(queue_id, event);
return logevent_id; return logevent_id;
} }
void MemoryStorage::pop(int64 logevent_id) { void MemoryStorage::pop(uint64 logevent_id) {
events_.erase(logevent_id); events_.erase(logevent_id);
} }

View File

@ -47,7 +47,7 @@ class TQueue {
double expires_at; double expires_at;
}; };
struct RawEvent { struct RawEvent {
int64 logevent_id{0}; uint64 logevent_id{0};
EventId event_id; EventId event_id;
string data; string data;
int64 extra{0}; int64 extra{0};
@ -60,8 +60,8 @@ class TQueue {
using RawEvent = TQueue::RawEvent; using RawEvent = TQueue::RawEvent;
virtual ~Callback() { virtual ~Callback() {
} }
virtual int64 push(QueueId queue_id, const RawEvent &event) = 0; virtual uint64 push(QueueId queue_id, const RawEvent &event) = 0;
virtual void pop(int64 logevent_id) = 0; virtual void pop(uint64 logevent_id) = 0;
}; };
virtual ~TQueue() { virtual ~TQueue() {
@ -97,8 +97,8 @@ template <class BinlogT>
class TQueueBinlog : public TQueue::Callback { class TQueueBinlog : public TQueue::Callback {
public: public:
TQueueBinlog(); TQueueBinlog();
int64 push(QueueId queue_id, const RawEvent &event) override; uint64 push(QueueId queue_id, const RawEvent &event) override;
void pop(int64 logevent_id) override; void pop(uint64 logevent_id) override;
Status replay(const BinlogEvent &binlog_event, TQueue &q); Status replay(const BinlogEvent &binlog_event, TQueue &q);
void set_binlog(std::shared_ptr<BinlogT> binlog) { void set_binlog(std::shared_ptr<BinlogT> binlog) {
@ -113,13 +113,13 @@ class TQueueBinlog : public TQueue::Callback {
class MemoryStorage : public TQueue::Callback { class MemoryStorage : public TQueue::Callback {
public: public:
int64 push(QueueId queue_id, const RawEvent &event) override; uint64 push(QueueId queue_id, const RawEvent &event) override;
void pop(int64 logevent_id) override; void pop(uint64 logevent_id) override;
void replay(TQueue &q); void replay(TQueue &q);
private: private:
int64 next_logevent_id_{1}; uint64 next_logevent_id_{1};
std::map<int64, std::pair<QueueId, RawEvent>> events_; std::map<uint64, std::pair<QueueId, RawEvent>> events_;
}; };
} // namespace td } // namespace td