HappenLee commented on code in PR #65847:
URL: https://github.com/apache/doris/pull/65847#discussion_r3688170762


##########
be/src/exprs/aggregate/aggregate_function_percentile.h:
##########
@@ -329,6 +329,241 @@ class AggregateFunctionPercentileApproxWeightedFourParams 
final
     }
 };
 
+struct PercentileApproxArrayState {
+    void init(const PaddedPODArray<Float64>& quantiles, const NullMap& 
null_map, size_t start,
+              size_t size, float compression = 10000) {
+        if (init_flag) {
+            return;
+        }
+
+        if (!std::isfinite(compression) || compression < 2048 || compression > 
10000) {
+            compression = 10000;
+        }
+        compressions = compression;
+        levels.quantiles.resize(size);
+        levels.permutation.resize(size);
+        for (size_t i = 0; i < size; ++i) {
+            if (null_map[start + i]) {
+                throw Exception(ErrorCode::INVALID_ARGUMENT,
+                                "percentile_approx_array quantile should not 
be null");
+            }
+            check_quantile(quantiles[start + i]);
+            levels.quantiles[i] = quantiles[start + i];
+            levels.permutation[i] = i;
+        }
+        if (!levels.empty()) {
+            digest = TDigest::create_unique(compressions);
+        }
+        init_flag = true;
+    }
+
+    void add_range(const Float64* values, size_t size) {
+        if (levels.empty()) {
+            return;
+        }
+        for (size_t i = 0; i < size; ++i) {
+            digest->add(static_cast<float>(values[i]));
+        }
+    }
+
+    void write(BufferWritable& buf) const {
+        buf.write_binary(init_flag);
+        if (!init_flag) {
+            return;
+        }
+
+        levels.write(buf);
+        buf.write_binary(compressions);
+        if (levels.empty()) {
+            return;
+        }
+        uint32_t serialize_size = digest->serialized_size();
+        std::string result(serialize_size, '0');
+        DCHECK(digest.get() != nullptr);

Review Comment:
   你这个DCHECK没有意义啊,380行都调用函数了,你这里还check什么,上面就挂了



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