acelyc111 commented on code in PR #1091:
URL: https://github.com/apache/incubator-pegasus/pull/1091#discussion_r945112243
##########
src/server/pegasus_server_impl.cpp:
##########
@@ -1187,21 +1187,23 @@ void
pegasus_server_impl::on_get_scanner(get_scanner_rpc rpc)
limiter->add_count();
- auto state = append_key_value_for_scan(
- resp.kvs,
+ auto state = validate_key_value_for_scan(
it->key(),
it->value(),
request.hash_key_filter_type,
request.hash_key_filter_pattern,
request.sort_key_filter_type,
request.sort_key_filter_pattern,
epoch_now,
- request.no_value,
- request.__isset.validate_partition_hash ?
request.validate_partition_hash : true,
- return_expire_ts);
+ request.__isset.validate_partition_hash ?
request.validate_partition_hash : true);
+
switch (state) {
case range_iteration_state::kNormal:
count++;
+ if (!request.only_return_count) {
Review Comment:
Should judge wether request.__isset.only_return_count is set at first, client
maybe old version, it have to keep compatitable.
##########
src/client_lib/pegasus_scanner_impl.cpp:
##########
@@ -162,13 +168,16 @@ void
pegasus_client_impl::pegasus_scanner_impl::_async_next_internal()
}
// valid data got
- std::string hash_key, sort_key;
- pegasus_restore_key(_kvs[_p].key, hash_key, sort_key);
- std::string value(_kvs[_p].value.data(), _kvs[_p].value.length());
- uint32_t expire_ts_seconds = _kvs[_p].__isset.expire_ts_seconds
- ?
static_cast<uint32_t>(_kvs[_p].expire_ts_seconds)
- : 0;
-
+ std::string hash_key, sort_key, value;
+ uint32_t expire_ts_seconds = 0;
+ // _kv_count == -1 means req just want to get data counts, not include
data value
+ if (_kv_count == -1) {
Review Comment:
How about add another variable to indicate directly what you want to do?
##########
src/client_lib/pegasus_scanner_impl.cpp:
##########
@@ -162,13 +168,16 @@ void
pegasus_client_impl::pegasus_scanner_impl::_async_next_internal()
}
// valid data got
- std::string hash_key, sort_key;
- pegasus_restore_key(_kvs[_p].key, hash_key, sort_key);
- std::string value(_kvs[_p].value.data(), _kvs[_p].value.length());
- uint32_t expire_ts_seconds = _kvs[_p].__isset.expire_ts_seconds
- ?
static_cast<uint32_t>(_kvs[_p].expire_ts_seconds)
- : 0;
-
+ std::string hash_key, sort_key, value;
+ uint32_t expire_ts_seconds = 0;
+ // _kv_count == -1 means req just want to get data counts, not include
data value
+ if (_kv_count == -1) {
Review Comment:
You should explain the case of `_kv_count == -1` and all other cases,
`_kv_count > -1` is only part of case you have to explain.
##########
src/server/pegasus_server_impl.cpp:
##########
@@ -1221,6 +1222,10 @@ void pegasus_server_impl::on_get_scanner(get_scanner_rpc
rpc)
it->Next();
}
+ if (request.only_return_count) {
+ resp.kvs.emplace_back(::dsn::apps::key_value());
Review Comment:
It's too tricky...
How much work if refactor it?
--
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]