HappenLee commented on code in PR #18785:
URL: https://github.com/apache/doris/pull/18785#discussion_r1171363864
##########
be/src/exprs/bloom_filter_func.h:
##########
@@ -91,7 +91,31 @@ class BloomFilterFuncBase {
void set_length(int64_t bloom_filter_length) { _bloom_filter_length =
bloom_filter_length; }
- Status init_with_fixed_length() { return
init_with_fixed_length(_bloom_filter_length); }
+ void set_build_bf_exactly(bool build_bf_exactly) { _build_bf_exactly =
build_bf_exactly; }
+
+ Status init_with_fixed_length() {
+ if (_build_bf_exactly) {
+ return Status::OK();
+ } else {
+ return init_with_fixed_length(_bloom_filter_length);
+ }
+ }
+
+ Status init_with_cardinality(const size_t build_bf_cardinality) {
+ if (_build_bf_exactly) {
+ // Use the same algorithm as
org.apache.doris.planner.RuntimeFilter#calculateFilterSize
+ constexpr double fpp = 0.05;
+ constexpr double k = 8; // BUCKET_WORDS
+ // m is the number of bits we would need to get the fpp specified
+ double m = -k * build_bf_cardinality / std::log(1 - std::pow(fpp,
1.0 / k));
+
+ // Handle case where ndv == 1 => ceil(log2(m/8)) < 0.
+ int log_filter_size = std::max(0, (int)(std::ceil(std::log(m / 8)
/ std::log(2))));
+ return init_with_fixed_length(((int64_t)1) << log_filter_size);
Review Comment:
the call seems not effect ?
--
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]