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

Function minhash_multi_process

join/LSH/LSH_benchmark_os.py:162–186  ·  view source on GitHub ↗
(file_list, q, param_dic, id)

Source from the content-addressed store, hash-verified

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