You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// u32:max cannot be reached with 64MB memory usage limit per filter even with a high fp rate (e.g. 0.9).
322
-
returnErr(BloomError::MaxNumScalingFilters);
327
+
returnErr(BloomError::BadCapacity);
323
328
}
324
329
};
325
330
// Reject the request, if the operation will result in creation of a filter of size greater than what is allowed.
@@ -373,7 +378,7 @@ impl BloomObject {
373
378
) -> Result<f64,BloomError>{
374
379
match fp_rate * tightening_ratio.powi(num_filters){
375
380
x if x > f64::MIN_POSITIVE => Ok(x),
376
-
_ => Err(BloomError::MaxNumScalingFilters),
381
+
_ => Err(BloomError::FalsePositiveReachesZero),
377
382
}
378
383
}
379
384
@@ -463,42 +468,78 @@ impl BloomObject {
463
468
}
464
469
}
465
470
466
-
pubfncalculate_if_wanted_capacity_is_valid(
471
+
/// This method is called from two different bloom commands BF.INFO and BF.INSERT. The functionality varies slightly on which command it
472
+
/// is called from. When called from BF.INFO this method is used to find the maximum possible size that the bloom object could scale to
473
+
/// without throwing an error. When called from BF.INSERT this method is used to determine if it is possible to reach the capacity that
474
+
/// has been provided.
475
+
///
476
+
/// # Arguments
477
+
///
478
+
/// * `capacity` - The size of the initial filter in the bloom object.
479
+
/// * `fp_rate` - the false positive rate for the bloom object
480
+
/// * `can_scale_to` - the capcity we check to see if it can scale to. If this method is called from BF.INFO this is set as -1 as we
481
+
/// want to check the maximum size we could scale up till
482
+
/// * `tightening_ratio` - The tightening ratio of the object
483
+
/// * `expansion` - The expanison rate of the object
484
+
///
485
+
/// # Returns
486
+
/// * i64 - The maximum capacity that can be reached if called from BF.INFO. If called from BF.INSERT the size it reached after going past max capacity
487
+
/// * ValkeyError - Can return two different errors:
488
+
/// VALIDATE_SCALE_TO_EXCEEDS_MAX_SIZE: When scaling to the wanted capacity would go over the bloom object memory limit
489
+
/// VALIDATE_SCALE_TO_FALSE_POSITIVE_INVALID: When scaling to the wanted capcity would cause the false positive rate to reach 0
0 commit comments