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

Function minhash_multi_process

join/LSH/LSH_benchmark_ws.py:161–185  ·  view source on GitHub ↗
(file_list, q, param_dic, id)

Source from the content-addressed store, hash-verified

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