MCPcopy Create free account
hub / github.com/BIT-DataLab/LakeBench / update

Method update

join/LSH/datasketch/minhash.py:123–153  ·  view source on GitHub ↗

Update this MinHash with a new value. The value will be hashed using the hash function specified by the `hashfunc` argument in the constructor. Args: b: The value to be hashed using the hash function specified. Example: To update with a new s

(self, b)

Source from the content-addressed store, hash-verified

121 return np.array(hashvalues, dtype=np.uint64)
122
123 def update(self, b):
124 '''Update this MinHash with a new value.
125 The value will be hashed using the hash function specified by
126 the `hashfunc` argument in the constructor.
127
128 Args:
129 b: The value to be hashed using the hash function specified.
130
131 Example:
132 To update with a new string value (using the default SHA1 hash
133 function, which requires bytes as input):
134
135 .. code-block:: python
136
137 minhash = Minhash()
138 minhash.update("new value".encode('utf-8'))
139
140 We can also use a different hash function, for example, `pyfarmhash`:
141
142 .. code-block:: python
143
144 import farmhash
145 def _hash_32(b):
146 return farmhash.hash32(b)
147 minhash = MinHash(hashfunc=_hash_32)
148 minhash.update("new value")
149 '''
150 hv = self.hashfunc(b)
151 a, b = self.permutations
152 phv = np.bitwise_and((a * hv + b) % _mersenne_prime, _max_hash)
153 self.hashvalues = np.minimum(phv, self.hashvalues)
154
155 def update_batch(self, b):
156 '''Update this MinHash with new values.

Callers 15

minhash_Lsh_forestFunction · 0.95
query_lsh_forestFunction · 0.95
entity_cellvalues_lshFunction · 0.95
query_lshFunction · 0.95
yago_entity_lshFunction · 0.95
minhash_Lsh_forestFunction · 0.95
query_lsh_forestFunction · 0.95
minhash_Lsh_forestFunction · 0.95
query_lsh_forestFunction · 0.95
minhash_multi_processFunction · 0.95
bootstrap_setsFunction · 0.95
minhash_multi_processFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected