@@ -8,11 +8,11 @@ use std::sync::atomic::{AtomicU64, Ordering};
8
8
9
9
use crate :: MetricType ;
10
10
11
- use super :: array:: AtomicU64Array ;
11
+ use super :: array:: AtomicU32Array ;
12
12
13
13
pub struct AtomicHistogram < const N : usize > {
14
14
id : MetricType ,
15
- buckets : AtomicU64Array < N > ,
15
+ buckets : AtomicU32Array < N > ,
16
16
upper_bounds : [ u64 ; N ] ,
17
17
sum : AtomicU64 ,
18
18
count : AtomicU64 ,
@@ -23,7 +23,7 @@ pub struct AtomicHistogram<const N: usize> {
23
23
impl < const N : usize > AtomicHistogram < N > {
24
24
pub const fn new ( id : MetricType , upper_bounds : [ u64 ; N ] ) -> Self {
25
25
Self {
26
- buckets : AtomicU64Array :: new ( ) ,
26
+ buckets : AtomicU32Array :: new ( ) ,
27
27
upper_bounds,
28
28
sum : AtomicU64 :: new ( 0 ) ,
29
29
count : AtomicU64 :: new ( 0 ) ,
@@ -41,7 +41,7 @@ impl<const N: usize> AtomicHistogram<N> {
41
41
42
42
for ( idx, upper_bound) in self . upper_bounds . iter ( ) . enumerate ( ) {
43
43
if value < * upper_bound {
44
- self . buckets . add ( idx, value ) ;
44
+ self . buckets . add ( idx, 1 ) ;
45
45
return ;
46
46
}
47
47
}
@@ -93,13 +93,13 @@ impl<const N: usize> AtomicHistogram<N> {
93
93
self . buckets
94
94
. inner ( )
95
95
. iter ( )
96
- . map ( |bucket| bucket. load ( Ordering :: Relaxed ) )
96
+ . map ( |bucket| bucket. load ( Ordering :: Relaxed ) as u64 )
97
97
}
98
98
99
99
pub fn buckets_vec ( & self ) -> Vec < u64 > {
100
100
let mut vec = Vec :: with_capacity ( N ) ;
101
101
for bucket in self . buckets . inner ( ) . iter ( ) {
102
- vec. push ( bucket. load ( Ordering :: Relaxed ) ) ;
102
+ vec. push ( bucket. load ( Ordering :: Relaxed ) as u64 ) ;
103
103
}
104
104
vec
105
105
}
0 commit comments