Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Commit

Permalink
fix invaild partition problem
Browse files Browse the repository at this point in the history
  • Loading branch information
CatKang committed Mar 2, 2017
1 parent 19fbefa commit 4362c17
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/node/zp_data_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,17 @@ Partition* Table::GetPartition(const std::string &key) {
slash::RWLock l(&partition_rw_, false);
if (partition_cnt_ > 0) {
int partition_id = std::hash<std::string>()(key) % partition_cnt_;
return partitions_[partition_id];
auto it = partitions_.find(partition_id);
if (it != partitions_.end()) {
return it->second;
}
}
return NULL;
}

Partition* Table::GetPartitionById(const int partition_id) {
slash::RWLock l(&partition_rw_, false);
auto it = partitions_.find(partition_id);
//std::map<int, Partition*>::const_iterator it = partitions_.find(partition_id);
if (it != partitions_.end()) {
return it->second;
}
Expand Down

0 comments on commit 4362c17

Please sign in to comment.