This is an automated email from the ASF dual-hosted git repository.
laiyingchun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git
The following commit(s) were added to refs/heads/master by this push:
new 0f32557e8 fix(shell): make the returned scanners sorted in ascending
order by partition index to support fetching specified partition in shell
(#2312)
0f32557e8 is described below
commit 0f32557e851921c034595977825e372fe327c6d6
Author: Guangshuo Wang <[email protected]>
AuthorDate: Tue Nov 4 18:07:43 2025 +0800
fix(shell): make the returned scanners sorted in ascending order by
partition index to support fetching specified partition in shell (#2312)
Fix https://github.com/apache/incubator-pegasus/issues/2309.
This pull request updates the logic for assigning partition indices in the
`async_get_unordered_scanners` method of `pegasus_client_impl.cpp`.
The change ensures that each scanner receives a unique and sequential
partition index, rather than decrementing from the total count, when the
variable max_split_count is greater than the number of partitions in the
table.
Partition assignment logic update:
* Changed the assignment of partition indices in the scanner creation loop
to use an incrementing `partition_index` variable, ensuring unique and
sequential indices for each partition instead of using a decrementing
`count`
value.
---
src/client_lib/pegasus_client_impl.cpp | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/src/client_lib/pegasus_client_impl.cpp
b/src/client_lib/pegasus_client_impl.cpp
index 1dd402bd0..c1b505155 100644
--- a/src/client_lib/pegasus_client_impl.cpp
+++ b/src/client_lib/pegasus_client_impl.cpp
@@ -1219,20 +1219,22 @@ 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;
- int split = count < max_split_count ? count : max_split_count;
- scanners.resize(split);
-
- int size = count / split;
- int more = count - size * split;
-
- for (int i = 0; i < split; i++) {
- int s = size + (i < more);
- std::vector<uint64_t> hash(s);
- for (int j = 0; j < s; j++)
- hash[j] = --count;
- scanners[i] =
- new pegasus_scanner_impl(_client, std::move(hash),
options, true, true);
+ const int split_count = std::min(response.partition_count,
max_split_count);
+ scanners.reserve(split_count);
+
+ const int split_size = response.partition_count / split_count;
+ const int remain = response.partition_count % split_count;
+ int partition_index = 0;
+
+ for (int i = 0; i < split_count; ++i) {
+ const int real_split_size = split_size + (i < remain ? 1 :
0);
+ std::vector<uint64_t> partition_hashes;
+ partition_hashes.reserve(real_split_size);
+ for (int j = 0; j < real_split_size; ++j) {
+ partition_hashes.push_back(partition_index++);
+ }
+ scanners.push_back(new pegasus_scanner_impl(
+ _client, std::move(partition_hashes), options, true,
true));
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]