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

Function minhash_multi_process

join/LSH/LSH_benchmark_wl.py:167–191  ·  view source on GitHub ↗
(file_list, q, param_dic, id)

Source from the content-addressed store, hash-verified

165 # print("{} end,size={}".format(id,len(sizes)))
166
167def minhash_multi_process(file_list, q, param_dic, id):
168 # print("{} start".format(id))
169 lsh = MinHashLSHEnsemble(threshold=param_dic['threshold'], num_perm=param_dic['num_perm'],
170 num_part=param_dic['num_part'], m=param_dic['m'], storage_config=param_dic['storage_config'])
171 for i, (lower, upper) in enumerate(param_dic["partitions"]):
172 lsh.lowers[i], lsh.uppers[i] = lower, upper
173 for i, sets_file in enumerate(file_list):
174 df = pd.read_csv(sets_file, dtype='str', lineterminator='\n').dropna()
175 columns = df.columns.tolist()
176 data = df.values.T.tolist()
177 for column, vals in zip(columns, data):
178 # 需要对value去重
179 vals = list(set(vals))
180 # 域的键值
181 key = sets_file + "." + column
182 # 生成minhash
183 mh = MinHash(param_dic['num_perm'], hashfunc=_hash_32)
184 for word in vals:
185 mh.update(str(word))
186 lsh.index((key, mh, len(vals)))
187 if id==0:
188 sys.stdout.write("\rId 0 Process Read and minhash {}/{} files".format(i+1, len(file_list)))
189 if id==0:
190 sys.stdout.write("\n")
191 q.put(lsh)
192
193# 将csv文件列表中每个表格中的column转换为三元组(minhashes, sets, keys)形式
194# @profile

Callers

nothing calls this directly

Calls 5

updateMethod · 0.95
indexMethod · 0.95
MinHashLSHEnsembleClass · 0.90
MinHashClass · 0.90
writeMethod · 0.80

Tested by

no test coverage detected