Copilot commented on code in PR #3116:
URL: https://github.com/apache/brpc/pull/3116#discussion_r2425113710


##########
src/bvar/detail/percentile.h:
##########
@@ -499,6 +552,56 @@ class Percentile {
     sampler_type* _sampler;
     std::string _debug_name;
 };
+#else
+class Percentile {
+public:
+    typedef GlobalPercentileSamples value_type;
+    typedef detail::AddPercentileSamples AddPercentileSamples;
+    typedef AddPercentileSamples Op;
+    typedef VoidOp InvOp;
+    typedef ReducerSampler<Percentile, value_type, Op, InvOp> sampler_type;
+
+    Percentile() = default;
+    DISALLOW_COPY_AND_MOVE(Percentile);
+    ~Percentile() noexcept {
+        if (NULL != _sampler) {
+            _sampler->destroy();
+        }
+    }
+
+    Op op() const { return Op(); }
+    InvOp inv_op() const { return InvOp(); }
+
+    sampler_type* get_sampler() {
+        if (NULL == _sampler) {
+            _sampler = new sampler_type(this);
+            _sampler->schedule();
+        }
+        return _sampler;
+    }
+
+    value_type reset();
+
+    value_type get_value() const {
+        LOG_EVERY_SECOND(ERROR) << "Percentile should never call this 
get_value()";

Review Comment:
   Error message should be more descriptive about why get_value() cannot be 
called and what alternative should be used.
   ```suggestion
           LOG_EVERY_SECOND(ERROR) << "Percentile::get_value() cannot be called 
directly because Percentile does not support direct value retrieval. Please use 
get_sampler()->get_value() to obtain the value instead.";
   ```



-- 
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]

Reply via email to