def add(self,item): """ Adds the item to the LogLog Sketch Arguments: - `item`: Item to be added the the sketch """ binword = getSHA1Bin(item) index = int(binword[:self._k],2) self._bucketList[index] = self._restrition_rule(max(self._bucketList[index],getIndex(binword[self._k:],160-self._k)))
def add(self,item): """ Adds the item to the LogLog Sketch Arguments: - `item`: Item to be added the the sketch """ binword = getSHA1Bin(item) pos = int(binword[:self._k],2) #Retrives the position of leftmost 1 aux = getIndex(binword[self._k:],160-self._k) # Sets its own register value to maximum value seen so far self._bucketList[pos] = max(aux,self._bucketList[pos])
def add(self,item): """ Adds the item to the LogLog Sketch Arguments: - `item`: Item to be added the the sketch """ binword = getSHA1Bin(item) pos = int(binword[:self._k],2) #Retrives the position of leftmost 1 aux = getIndex(binword[self._k:],160-self._k) ##The position cannot be bigger than the maximum number that can be fitted in wordsize bits index = min(aux,(1<<self._bucketSize)-1) newValue = max(int(self._bucketList[pos].to01(),2),index) self._bucketList[pos] = bitarray(bin(newValue)[2:])