File tree Expand file tree Collapse file tree
utils/src/bitmap/roaring/container Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,11 +49,17 @@ impl Default for Bitmap {
4949
5050impl From < & array:: Array > for Bitmap {
5151 fn from ( array : & array:: Array ) -> Self {
52- let mut container = Self :: new ( ) ;
52+ let mut words = [ 0u64 ; WORDS ] ;
5353 for value in array. iter ( ) {
54- container. insert ( value) ;
54+ let word_idx = ( value >> 6 ) as usize ;
55+ let bit_idx = value & 63 ;
56+ words[ word_idx] |= 1u64 << bit_idx;
57+ }
58+ Self {
59+ words,
60+ cardinality : array. len ( ) as u32 ,
61+ run_count : count_runs ( & words) ,
5562 }
56- container
5763 }
5864}
5965
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ pub mod bitmap;
3535pub mod run;
3636
3737#[ cfg( not( feature = "std" ) ) ]
38- use alloc:: boxed:: Box ;
38+ use alloc:: { boxed:: Box , vec :: Vec } ;
3939pub use array:: Array ;
4040pub use bitmap:: Bitmap ;
4141use bytes:: { Buf , BufMut } ;
You can’t perform that action at this time.
0 commit comments