Skip to content

Commit

Permalink
fix: PartitionInfo::operator< should return boolean value (OpenAtom…
Browse files Browse the repository at this point in the history
  • Loading branch information
4kangjc authored May 5, 2023
1 parent 66a2de6 commit 430d62a
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions include/pika_define.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,26 +210,20 @@ struct BinlogChip {
struct PartitionInfo {
PartitionInfo(const std::string& table_name, uint32_t partition_id)
: table_name_(table_name), partition_id_(partition_id) {}

PartitionInfo() : partition_id_(0) {}

bool operator==(const PartitionInfo& other) const {
if (table_name_ == other.table_name_ && partition_id_ == other.partition_id_) {
return true;
}
return false;
}
int operator<(const PartitionInfo& other) const {
int ret = strcmp(table_name_.data(), other.table_name_.data());
if (!ret) {
if (partition_id_ < other.partition_id_) {
ret = -1;
} else if (partition_id_ > other.partition_id_) {
ret = 1;
} else {
ret = 0;
}
}
return ret;

bool operator<(const PartitionInfo& other) const {
return table_name_ < other.table_name_ || (table_name_ == other.table_name_ && partition_id_ < other.partition_id_);
}

std::string ToString() const { return "(" + table_name_ + ":" + std::to_string(partition_id_) + ")"; }
std::string table_name_;
uint32_t partition_id_;
Expand Down

0 comments on commit 430d62a

Please sign in to comment.