Skip to content

Commit

Permalink
Fix logevent_id type.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: a609c2f25c1898defe031ce90c72957a031e3f65
  • Loading branch information
levlam committed Jun 11, 2020
1 parent 22c9927 commit 2a6eebe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions tddb/td/db/TQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ TQueueBinlog<BinlogT>::TQueueBinlog() {
diff_ = Clocks::system() - Time::now();
}
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;
log_event.queue_id = queue_id;
log_event.event_id = event.event_id.value();
Expand All @@ -375,7 +375,7 @@ int64 TQueueBinlog<BinlogT>::push(QueueId queue_id, const RawEvent &event) {
}

template <class BinlogT>
void TQueueBinlog<BinlogT>::pop(int64 logevent_id) {
void TQueueBinlog<BinlogT>::pop(uint64 logevent_id) {
binlog_->erase(logevent_id);
}

Expand All @@ -399,13 +399,13 @@ Status TQueueBinlog<BinlogT>::replay(const BinlogEvent &binlog_event, TQueue &q)
template class TQueueBinlog<BinlogInterface>;
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;
events_[logevent_id] = std::make_pair(queue_id, event);

return logevent_id;
}
void MemoryStorage::pop(int64 logevent_id) {
void MemoryStorage::pop(uint64 logevent_id) {
events_.erase(logevent_id);
}

Expand Down
18 changes: 9 additions & 9 deletions tddb/td/db/TQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TQueue {
double expires_at;
};
struct RawEvent {
int64 logevent_id{0};
uint64 logevent_id{0};
EventId event_id;
string data;
int64 extra{0};
Expand All @@ -60,8 +60,8 @@ class TQueue {
using RawEvent = TQueue::RawEvent;
virtual ~Callback() {
}
virtual int64 push(QueueId queue_id, const RawEvent &event) = 0;
virtual void pop(int64 logevent_id) = 0;
virtual uint64 push(QueueId queue_id, const RawEvent &event) = 0;
virtual void pop(uint64 logevent_id) = 0;
};

virtual ~TQueue() {
Expand Down Expand Up @@ -97,8 +97,8 @@ template <class BinlogT>
class TQueueBinlog : public TQueue::Callback {
public:
TQueueBinlog();
int64 push(QueueId queue_id, const RawEvent &event) override;
void pop(int64 logevent_id) override;
uint64 push(QueueId queue_id, const RawEvent &event) override;
void pop(uint64 logevent_id) override;
Status replay(const BinlogEvent &binlog_event, TQueue &q);

void set_binlog(std::shared_ptr<BinlogT> binlog) {
Expand All @@ -113,13 +113,13 @@ class TQueueBinlog : public TQueue::Callback {

class MemoryStorage : public TQueue::Callback {
public:
int64 push(QueueId queue_id, const RawEvent &event) override;
void pop(int64 logevent_id) override;
uint64 push(QueueId queue_id, const RawEvent &event) override;
void pop(uint64 logevent_id) override;
void replay(TQueue &q);

private:
int64 next_logevent_id_{1};
std::map<int64, std::pair<QueueId, RawEvent>> events_;
uint64 next_logevent_id_{1};
std::map<uint64, std::pair<QueueId, RawEvent>> events_;
};

} // namespace td

0 comments on commit 2a6eebe

Please sign in to comment.