def increment(self, item):
     """
     Counts an item
     """
     mm_hash = smhasher.murmur3_x64_128(str(item))
     offset = mm_hash % self.bit_map.length()
     self.bit_map[offset] = True
Exemple #2
0
 def increment(self, element: object):
     element_str = str(element).encode('utf-8')
     if self.hashing_function == 'murmurhash3':
         offset = smhasher.murmur3_x64_128(element_str) % self.bitmap_size
     else:
         hasher = pyhash.lookup3()
         offset = hasher(element_str) % self.bitmap_size
     self.bit_map[offset] = True
    def _get_page_reference(cls, req):
        # Include `url parameters` to `page reference` in case
        # `URL_IGNORE_PARAMETERS` is set up to `False`.
        page_parameters = cls._get_page_url_parameters(req)
        page_url = cls._get_page_url(req)

        # Encode `url_parameters` and `url`.
        hex_url = hex(
            smhasher.murmur3_x64_128('{}{}'.format(page_url, page_parameters)))

        # Return unique page reference that will be used as `redis key`.
        return '{}:{}'.format(REDIS_PREFIX, hex_url)
Exemple #4
0
 def increment(self, element: object) -> None:
     element_str = str(element).encode('utf-8')
     if self.hashing_function == 'murmurhash3':
         h = smhasher.murmur3_x64_128(
             element_str, self.seed) % self.hash_function_upper_bound
     elif self.hashing_function == 'mmh3':
         h = mmh3.hash(element_str,
                       seed=self.seed) % self.hash_function_upper_bound
     else:
         hasher = pyhash.lookup3()
         h = hasher(element_str, str(
             self.seed)) % self.hash_function_upper_bound
     self.bitmap[self.count_trailing_zeros(h, self.sketch_size)] = True