Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,12 @@ rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
mur3 = { version = "0.1.0" }

[lints.rust]
unknown_lints = "deny"
unsafe_code = "deny"
unused_must_use = "deny"

[lints.clippy]
dbg_macro = "deny"
too_many_arguments = "allow"
4 changes: 2 additions & 2 deletions src/hll/aux_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//! Stores slot-value pairs for values that don't fit in the 4-bit main array.
//! Uses open addressing with stride-based probing for collision resolution.

use crate::hll::{RESIZE_DENOM, RESIZE_NUMER, get_slot, get_value, pack_coupon};
use crate::hll::{RESIZE_DENOMINATOR, RESIZE_NUMERATOR, get_slot, get_value, pack_coupon};

const ENTRY_EMPTY: u32 = 0;

Expand Down Expand Up @@ -175,7 +175,7 @@ impl AuxMap {
/// Check if we need to grow the hash table (75% load factor)
fn check_grow(&mut self) {
let size = 1 << self.lg_size;
if (RESIZE_DENOM * self.count) > (RESIZE_NUMER * size) {
if (RESIZE_DENOMINATOR * self.count) > (RESIZE_NUMERATOR * size) {
self.grow();
}
}
Expand Down
29 changes: 14 additions & 15 deletions src/hll/cubic_interpolation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ fn interpolate_using_x_arr_and_y_stride(
}

/// Cubic interpolation using the Lagrange interpolation formula.
#[allow(clippy::too_many_arguments)]
fn cubic_interpolate(
x0: f64,
y0: f64,
Expand All @@ -122,20 +121,20 @@ fn cubic_interpolate(
y3: f64,
x: f64,
) -> f64 {
let l0_numer = (x - x1) * (x - x2) * (x - x3);
let l1_numer = (x - x0) * (x - x2) * (x - x3);
let l2_numer = (x - x0) * (x - x1) * (x - x3);
let l3_numer = (x - x0) * (x - x1) * (x - x2);

let l0_denom = (x0 - x1) * (x0 - x2) * (x0 - x3);
let l1_denom = (x1 - x0) * (x1 - x2) * (x1 - x3);
let l2_denom = (x2 - x0) * (x2 - x1) * (x2 - x3);
let l3_denom = (x3 - x0) * (x3 - x1) * (x3 - x2);

let term0 = y0 * l0_numer / l0_denom;
let term1 = y1 * l1_numer / l1_denom;
let term2 = y2 * l2_numer / l2_denom;
let term3 = y3 * l3_numer / l3_denom;
let l0_numerator = (x - x1) * (x - x2) * (x - x3);
let l1_numerator = (x - x0) * (x - x2) * (x - x3);
let l2_numerator = (x - x0) * (x - x1) * (x - x3);
let l3_numerator = (x - x0) * (x - x1) * (x - x2);

let l0_denominator = (x0 - x1) * (x0 - x2) * (x0 - x3);
let l1_denominator = (x1 - x0) * (x1 - x2) * (x1 - x3);
let l2_denominator = (x2 - x0) * (x2 - x1) * (x2 - x3);
let l3_denominator = (x3 - x0) * (x3 - x1) * (x3 - x2);

let term0 = y0 * l0_numerator / l0_denominator;
let term1 = y1 * l1_numerator / l1_denominator;
let term2 = y2 * l2_numerator / l2_denominator;
let term3 = y3 * l3_numerator / l3_denominator;

term0 + term1 + term2 + term3
}
Expand Down
4 changes: 2 additions & 2 deletions src/hll/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ const KEY_MASK_26: u32 = (1 << KEY_BITS_26) - 1;
const COUPON_RSE_FACTOR: f64 = 0.409; // At transition point not the asymptote
const COUPON_RSE: f64 = COUPON_RSE_FACTOR / (1 << 13) as f64;

const RESIZE_NUMER: u32 = 3; // Resize at 3/4 = 75% load factor
const RESIZE_DENOM: u32 = 4;
const RESIZE_NUMERATOR: u32 = 3; // Resize at 3/4 = 75% load factor
const RESIZE_DENOMINATOR: u32 = 4;

/// Extract slot number (low 26 bits) from coupon
#[inline]
Expand Down
6 changes: 3 additions & 3 deletions src/hll/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::hll::container::Container;
use crate::hll::hash_set::HashSet;
use crate::hll::list::List;
use crate::hll::serialization::*;
use crate::hll::{HllType, NumStdDev, RESIZE_DENOM, RESIZE_NUMER, coupon};
use crate::hll::{HllType, NumStdDev, RESIZE_DENOMINATOR, RESIZE_NUMERATOR, coupon};

/// Current sketch mode
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
Expand Down Expand Up @@ -119,8 +119,8 @@ impl HllSketch {
}
Mode::Set { set, hll_type } => {
set.update(coupon);
let should_promote = RESIZE_DENOM as usize * set.container().len()
> RESIZE_NUMER as usize * set.container().capacity();
let should_promote = RESIZE_DENOMINATOR as usize * set.container().len()
> RESIZE_NUMERATOR as usize * set.container().capacity();
if should_promote {
self.mode = if set.container().lg_size() == self.lg_config_k as usize - 3 {
promote_container_to_array(set.container(), *hll_type, self.lg_config_k)
Expand Down
3 changes: 2 additions & 1 deletion typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
# under the License.

[default.extend-words]
"NUMER" = "NUMER"
# False-Positive Abbreviations
"PREINTS" = "PREINTS"

[files]
extend-exclude = []