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
Copy file name to clipboardExpand all lines: .travis.yml
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -13,9 +13,9 @@ addons:
13
13
14
14
env:
15
15
global:
16
-
- FMT_VERSION=nightly-2018-10-14
17
-
- CLIPPY_VERSION=nightly-2018-10-14
18
-
- DOCS_RS_VERSION=nightly-2018-10-14#should be nightly-2018-06-03 but packed_simd fails https://github.com/onur/docs.rs/blob/32102ce458b34f750ef190182116d9583491a64b/Vagrantfile#L50
/// An implementation of the [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) data structure with *bias correction*.
58
125
///
59
126
/// See [*HyperLogLog: the analysis of a near-optimal cardinality estimation algorithm*](http://algo.inria.fr/flajolet/Publications/FlFuGaMe07.pdf) and [*HyperLogLog in Practice: Algorithmic Engineering of a State of The Art Cardinality Estimation Algorithm*](https://ai.google/research/pubs/pub40671) for background on HyperLogLog with bias correction.
@@ -75,13 +142,13 @@ where
75
142
/// Create an empty `HyperLogLog` data structure with the specified error tolerance.
76
143
pubfnnew(error_rate:f64) -> Self{
77
144
assert!(0.0 < error_rate && error_rate < 1.0);
78
-
let p = (f64::log2(1.04 / error_rate)*2.0).ceil()asu8;
145
+
let p = f64_to_u8((f64::log2(1.04 / error_rate)*2.0).ceil());
79
146
assert!(0 < p && p < 64);
80
147
let alpha = Self::get_alpha(p);
81
148
Self{
82
149
alpha,
83
150
zero:1 << p,
84
-
sum:(1 << p)asf64,
151
+
sum:f64::from(1 << p),
85
152
p,
86
153
m:vec![0;1 << p].into_boxed_slice(),
87
154
marker:PhantomData,
@@ -93,7 +160,7 @@ where
93
160
Self{
94
161
alpha: hll.alpha,
95
162
zero: hll.m.len(),
96
-
sum: hll.m.len()asf64,
163
+
sum:usize_to_f64(hll.m.len()),
97
164
p: hll.p,
98
165
m:vec![0; hll.m.len()].into_boxed_slice(),
99
166
marker:PhantomData,
@@ -109,14 +176,14 @@ where
109
176
let j = x &(self.m.len()asu64 - 1);
110
177
let w = x >> self.p;
111
178
let rho = Self::get_rho(w,64 - self.p);
112
-
let mjr = &mutself.m[j asusize];
179
+
let mjr = &mutself.m[usize::try_from(j).unwrap()];
Copy file name to clipboardExpand all lines: src/lib.rs
+34-5Lines changed: 34 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@
22
22
//! As these implementations are often in hot code paths, unsafe is used, albeit only when necessary to a) achieve the asymptotically optimal algorithm or b) mitigate an observed bottleneck.
0 commit comments