LindaSummer commented on code in PR #2849:
URL: https://github.com/apache/kvrocks/pull/2849#discussion_r2079690321
##########
src/commands/cmd_tdigest.cc:
##########
@@ -265,13 +265,16 @@ class CommandTDigestQuantile : public Commander {
}
return {Status::RedisExecErr, s.ToString()};
}
- if (values_.empty()) {
- return {Status::RedisExecErr, "invalid quantile or empty tdigest"};
- }
std::vector<std::string> quantile_strings;
quantile_strings.reserve(result.quantiles.size());
- for (const auto &q : result.quantiles) {
- quantile_strings.push_back(std::to_string(q));
+ if (!result.has_centroids) {
+ for (size_t i = 0; i < values_.size(); ++i) {
+ quantile_strings.emplace_back("nan");
Review Comment:
Hi @SharonIV0x86 ,
Maybe we could make "nan" a constexpr literal string in this file. 😊
It would also be used in other commands.
Best Regards,
Edward
##########
src/types/redis_tdigest.cc:
##########
@@ -225,6 +225,10 @@ rocksdb::Status TDigest::Quantile(engine::Context& ctx,
const Slice& digest_name
if (auto status = dumpCentroids(ctx, ns_key, metadata, ¢roids);
!status.ok()) {
return status;
}
+ if (centroids.empty()) {
Review Comment:
Hi @SharonIV0x86 ,
At the first time we load the metadata, we should know this tdigest has no
data inside it.
This could be checked before the centroids retrieving.
Best Regards,
Edward
--
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]