pub fn sketch(&mut self, to_sketch : &T) -> Result <(),()> {
        let m = self.hsketch.len();
        let mut a_upper = m - 1;
        let unit_range = Uniform::<f64>::new(0., 1.);
        //
        // hash! even if with NoHashHasher. In this case T must be u64 or u32
        let mut hasher = self.b_hasher.build_hasher();
        to_sketch.hash(&mut hasher);
        let hval1 : u64 = hasher.finish();
        // Then initialize random numbers generators with seedxor,
        // we have one random generator for each element to sketch
        // CAVEAT : if collisions occurs the generators used are not in bijection with data
        // In probminhash we imposed T to verifiy Into<usize>. We have to be coherent..
        let mut rand_generator = Xoshiro256PlusPlus::seed_from_u64(hval1);
//        trace!("sketch hval1 :  {:?} ",hval1); // needs T : Debug
        //
        let mut j:usize = 0;
        let irank = (self.item_rank) as i64;
        while j <= a_upper {
            let r:f64 = unit_range.sample(&mut rand_generator);
            let k = Uniform::<usize>::new(j, m).sample(&mut rand_generator); // m beccause upper bound of range is excluded
            //
            if self.q[j] != irank {
                self.q[j] = irank;
                self.p[j] = j;
            }
            if self.q[k] != irank {
                self.q[k] = irank;
                self.p[k] = k;
            }
            let tmp_swap = self.p[j];
            self.p[j] = self.p[k];
            self.p[k] = tmp_swap;
            //
            // update hsketch and counters
            let rpj = r+(j as f64);
            if rpj  < self.hsketch[self.p[j]]  {
                // update of signature of rank j
                let j_2 = cmp::min(self.hsketch[self.p[j]] as usize, m-1);
                self.hsketch[self.p[j]] = rpj;
                if j < j_2 {
                    // we can decrease counter of upper parts of b and update upper
                    self.b[j_2] = self.b[j_2]-1;
                    self.b[j] += 1;
                    while self.b[a_upper] == 0 {
                        a_upper = a_upper - 1;
                    } // end if j < j_2
                } // end update a_upper
            } // end if r+j < ...
            j+=1;
        } // end of while on j <= upper
        self.item_rank +=1;            
        //
        return Ok(());
    }
/// Insert an item in the set to sketch.  
/// It can be used in streaming to update current sketch
Insert an item in the set to sketch.
It can be used in streaming to update current sketch
Insert an item in the set to sketch . It can be used in streaming to update current sketch
pub fn sketch(&mut self, to_sketch : &T) -> Result <(),()> {
        let m = self.hsketch.len();
        let mut a_upper = m - 1;
        let unit_range = Uniform::<f64>::new(0., 1.);
        //
        // hash! even if with NoHashHasher. In this case T must be u64 or u32
        let mut hasher = self.b_hasher.build_hasher();
        to_sketch.hash(&mut hasher);
        let hval1 : u64 = hasher.finish();
        // Then initialize random numbers generators with seedxor,
        // we have one random generator for each element to sketch
        // CAVEAT : if collisions occurs the generators used are not in bijection with data
        // In probminhash we imposed T to verifiy Into<usize>. We have to be coherent..
        let mut rand_generator = Xoshiro256PlusPlus::seed_from_u64(hval1);
//        trace!("sketch hval1 :  {:?} ",hval1); // needs T : Debug
        //
        let mut j:usize = 0;
        let irank = (self.item_rank) as i64;
        while j <= a_upper {
            let r:f64 = unit_range.sample(&mut rand_generator);
            let k = Uniform::<usize>::new(j, m).sample(&mut rand_generator); // m beccause upper bound of range is excluded
            //
            if self.q[j] != irank {
                self.q[j] = irank;
                self.p[j] = j;
            }
            if self.q[k] != irank {
                self.q[k] = irank;
                self.p[k] = k;
            }
            let tmp_swap = self.p[j];
            self.p[j] = self.p[k];
            self.p[k] = tmp_swap;
            //
            // update hsketch and counters
            let rpj = r+(j as f64);
            if rpj  < self.hsketch[self.p[j]]  {
                // update of signature of rank j
                let j_2 = cmp::min(self.hsketch[self.p[j]] as usize, m-1);
                self.hsketch[self.p[j]] = rpj;
                if j < j_2 {
                    // we can decrease counter of upper parts of b and update upper
                    self.b[j_2] = self.b[j_2]-1;
                    self.b[j] += 1;
                    while self.b[a_upper] == 0 {
                        a_upper = a_upper - 1;
                    } // end if j < j_2
                } // end update a_upper
            } // end if r+j < ...
            j+=1;
        } // end of while on j <= upper
        self.item_rank +=1;            
        //
        return Ok(());
    }
pub fn sketch ( & mut self , to_sketch : & T ) -> Result < ( ) , ( ) > { let m = self . hsketch . len ( ) ; let mut a_upper = m - 1 ; let unit_range = Uniform :: < f64 > :: new ( 0. , 1. ) ; // // hash! even if with NoHashHasher. In this case T must be u64 or u32 let mut hasher = self . b_hasher . build_hasher ( ) ; to_sketch . hash ( & mut hasher ) ; let hval1 : u64 = hasher . finish ( ) ; // Then initialize random numbers generators with seedxor, // we have one random generator for each element to sketch // CAVEAT : if collisions occurs the generators used are not in bijection with data // In probminhash we imposed T to verifiy Into<usize>. We have to be coherent.. let mut rand_generator = Xoshiro256PlusPlus :: seed_from_u64 ( hval1 ) ; //        trace!("sketch hval1 :  {:?} ",hval1); // needs T : Debug // let mut j : usize = 0 ; let irank = ( self . item_rank ) as i64 ; while j <= a_upper { let r : f64 = unit_range . sample ( & mut rand_generator ) ; let k = Uniform :: < usize > :: new ( j , m ) . sample ( & mut rand_generator ) ; // m beccause upper bound of range is excluded // if self . q [ j ] != irank { self . q [ j ] = irank ; self . p [ j ] = j ; } if self . q [ k ] != irank { self . q [ k ] = irank ; self . p [ k ] = k ; } let tmp_swap = self . p [ j ] ; self . p [ j ] = self . p [ k ] ; self . p [ k ] = tmp_swap ; // // update hsketch and counters let rpj = r + ( j as f64 ) ; if rpj < self . hsketch [ self . p [ j ] ] { // update of signature of rank j let j_2 = cmp :: min ( self . hsketch [ self . p [ j ] ] as usize , m - 1 ) ; self . hsketch [ self . p [ j ] ] = rpj ; if j < j_2 { // we can decrease counter of upper parts of b and update upper self . b [ j_2 ] = self . b [ j_2 ] - 1 ; self . b [ j ] += 1 ; while self . b [ a_upper ] == 0 { a_upper = a_upper - 1 ; } // end if j < j_2 } // end update a_upper } // end if r+j < ... j += 1 ; } // end of while on j <= upper self . item_rank += 1 ; // return Ok ( ( ) ) ; }
Insert an item in the set to sketch.
Insert an item in the set to sketch .
&mut self
to_sketch
&T