MCPcopy Create free account
hub / github.com/Tencent/phxqueue / GetQueueByRank

Method GetQueueByRank

phxqueue/config/topicconfig.cpp:416–433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

414}
415
416comm::RetCode TopicConfig::GetQueueByRank(const int queue_info_id, const uint64_t rank, int &queue) const {
417 auto &&it = impl_->queue_info_id2ranges.find(queue_info_id);
418 if (it == impl_->queue_info_id2ranges.end()) return comm::RetCode::RET_ERR_RANGE_QUEUE_INFO;
419 auto &&ranges = it->second;
420
421 if (0 == ranges.size()) return comm::RetCode::RET_ERR_RANGE_RANK;
422
423 uint64_t r{rank};
424 for (auto &&range : ranges) {
425 uint64_t w{range.second - range.first + 1};
426 if (r >= w) r -= w;
427 else {
428 queue = (int)(range.first + r);
429 return comm::RetCode::RET_OK;
430 }
431 }
432 return comm::RetCode::RET_ERR_RANGE_RANK;
433}
434
435comm::RetCode TopicConfig::GetQueueByLoopRank(const int queue_info_id, const uint64_t rank, int &queue) const {
436 comm::RetCode ret;

Callers 2

CheckTopicConfigMethod · 0.80
TestTopicConfigMethod · 0.80

Calls

no outgoing calls

Tested by 2

CheckTopicConfigMethod · 0.64
TestTopicConfigMethod · 0.64