Skip to content

Commit

Permalink
bugfix: crc32 slot distribute don't fit non 2 power slot number
Browse files Browse the repository at this point in the history
  • Loading branch information
kernelai committed Sep 23, 2020
1 parent d94339f commit 161fe22
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/pika_data_distribution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ void Crc32::Crc32TableInit(uint32_t poly) {

uint32_t Crc32::Distribute(const std::string &str, uint32_t partition_num) {
uint32_t crc = Crc32Update(0, str.data(), (int)str.size());
// partition_num need to minus 1
assert(partition_num > 1);
return (int)(crc & (partition_num == 0 ? 0 : (partition_num - 1)));
assert(partition_num != 0);
return crc % partition_num;
}

uint32_t Crc32::Crc32Update(uint32_t crc, const char* buf, int len) {
Expand Down

0 comments on commit 161fe22

Please sign in to comment.