PragmaTwice commented on code in PR #3268:
URL: https://github.com/apache/kvrocks/pull/3268#discussion_r2548890153
##########
src/types/redis_tdigest.h:
##########
@@ -132,4 +253,39 @@ class TDigest : public SubKeyScanner {
Centroid* centroid) const;
};
+template <bool reverse>
+rocksdb::Status TDigest::Rank(engine::Context& ctx, const Slice& digest_name,
const std::vector<double>& inputs,
+ std::vector<int>& result) {
+ auto ns_key = AppendNamespacePrefix(digest_name);
+ TDigestMetadata metadata;
+ {
+ LockGuard guard(storage_->GetLockManager(), ns_key);
+
+ if (auto status = getMetaDataByNsKey(ctx, ns_key, &metadata);
!status.ok()) {
+ return status;
+ }
+
+ if (metadata.total_observations == 0) {
+ result.resize(inputs.size(), -2);
+ return rocksdb::Status::OK();
+ }
+
+ if (auto status = mergeNodes(ctx, ns_key, &metadata); !status.ok()) {
+ return status;
+ }
+ }
+
+ std::vector<Centroid> centroids;
+ if (auto status = dumpCentroids(ctx, ns_key, metadata, ¢roids);
!status.ok()) {
+ return status;
+ }
+
+ auto dump_centroids = DummyCentroids(metadata, centroids);
+ auto status = TDigestRank<DummyCentroids&, reverse>(dump_centroids, inputs,
result);
Review Comment:
```suggestion
auto status = TDigestRank<reverse>(dump_centroids, inputs, result);
```
--
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]