empiredan commented on code in PR #2312:
URL:
https://github.com/apache/incubator-pegasus/pull/2312#discussion_r2481024858
##########
src/client_lib/pegasus_client_impl.cpp:
##########
@@ -1219,18 +1219,20 @@ void pegasus_client_impl::async_get_unordered_scanners(
if (err == ERR_OK) {
::dsn::unmarshall(resp, response);
if (response.err == ERR_OK) {
- unsigned int count = response.partition_count;
+ auto count = response.partition_count;
int split = count < max_split_count ? count : max_split_count;
scanners.resize(split);
int size = count / split;
int more = count - size * split;
Review Comment:
```suggestion
const int split_size = response.partition_count /
split_count;
const int remain = response.partition_count - split_size *
split_count;
```
##########
src/client_lib/pegasus_client_impl.cpp:
##########
@@ -1219,18 +1219,20 @@ void pegasus_client_impl::async_get_unordered_scanners(
if (err == ERR_OK) {
::dsn::unmarshall(resp, response);
if (response.err == ERR_OK) {
- unsigned int count = response.partition_count;
+ auto count = response.partition_count;
int split = count < max_split_count ? count : max_split_count;
scanners.resize(split);
int size = count / split;
int more = count - size * split;
+ int partition_index = 0;
for (int i = 0; i < split; i++) {
Review Comment:
```suggestion
for (int i = 0; i < split_count; ++i) {
```
##########
src/client_lib/pegasus_client_impl.cpp:
##########
@@ -1219,18 +1219,20 @@ void pegasus_client_impl::async_get_unordered_scanners(
if (err == ERR_OK) {
::dsn::unmarshall(resp, response);
if (response.err == ERR_OK) {
- unsigned int count = response.partition_count;
+ auto count = response.partition_count;
int split = count < max_split_count ? count : max_split_count;
scanners.resize(split);
int size = count / split;
int more = count - size * split;
+ int partition_index = 0;
for (int i = 0; i < split; i++) {
- int s = size + (i < more);
+ int s = size + static_cast<int>(i < more);
std::vector<uint64_t> hash(s);
Review Comment:
```suggestion
const int real_split_size = split_size + (i < remain ? 1
: 0);
std::vector<uint64_t> partition_hashes;
partition_hashes.reserve(real_split_size);
```
##########
src/client_lib/pegasus_client_impl.cpp:
##########
@@ -1219,18 +1219,20 @@ void pegasus_client_impl::async_get_unordered_scanners(
if (err == ERR_OK) {
::dsn::unmarshall(resp, response);
if (response.err == ERR_OK) {
- unsigned int count = response.partition_count;
+ auto count = response.partition_count;
int split = count < max_split_count ? count : max_split_count;
scanners.resize(split);
int size = count / split;
int more = count - size * split;
+ int partition_index = 0;
for (int i = 0; i < split; i++) {
- int s = size + (i < more);
+ int s = size + static_cast<int>(i < more);
std::vector<uint64_t> hash(s);
- for (int j = 0; j < s; j++)
- hash[j] = --count;
+ for (int j = 0; j < s; j++) {
+ hash[j] = partition_index++;
+ }
scanners[i] =
new pegasus_scanner_impl(_client, std::move(hash),
options, true, true);
Review Comment:
```suggestion
scanners.push_back(new pegasus_scanner_impl(_client,
std::move(partition_hashes), options, true, true));
```
##########
src/client_lib/pegasus_client_impl.cpp:
##########
@@ -1219,18 +1219,20 @@ void pegasus_client_impl::async_get_unordered_scanners(
if (err == ERR_OK) {
::dsn::unmarshall(resp, response);
if (response.err == ERR_OK) {
- unsigned int count = response.partition_count;
+ auto count = response.partition_count;
int split = count < max_split_count ? count : max_split_count;
scanners.resize(split);
Review Comment:
```suggestion
const int split_count = std::min(response.partition_count,
max_split_count);
scanners.reserve(split_count);
```
##########
src/client_lib/pegasus_client_impl.cpp:
##########
@@ -1219,18 +1219,20 @@ void pegasus_client_impl::async_get_unordered_scanners(
if (err == ERR_OK) {
::dsn::unmarshall(resp, response);
if (response.err == ERR_OK) {
- unsigned int count = response.partition_count;
+ auto count = response.partition_count;
int split = count < max_split_count ? count : max_split_count;
scanners.resize(split);
int size = count / split;
int more = count - size * split;
+ int partition_index = 0;
for (int i = 0; i < split; i++) {
- int s = size + (i < more);
+ int s = size + static_cast<int>(i < more);
std::vector<uint64_t> hash(s);
- for (int j = 0; j < s; j++)
- hash[j] = --count;
+ for (int j = 0; j < s; j++) {
+ hash[j] = partition_index++;
+ }
Review Comment:
```suggestion
for (int j = 0; j < real_split_size; ++j) {
partition_hashes.push_back(partition_index++);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]