NEW: compare without target tree and use hset to store the compared index

This commit is contained in:
fixminer
2020-08-16 00:29:05 +02:00
parent d0b984e1cf
commit b5b57e9ba8
2 changed files with 24 additions and 14 deletions
+17 -10
View File
@@ -52,20 +52,18 @@ delPattern = 'DEL (' + '|'.join(ast) + ')@@(.*)@AT@'
insPattern = 'INS (' + '|'.join(ast) + ')@@(.*)@TO@ (' + '|'.join(ast) + ')@@(.*)@AT@'
updPattern = 'UPD (' + '|'.join(ast) + ')@@(.*)@TO@(.*)@AT@'
def loadPairMulti(root,clusterPath,level):
def loadPairMulti(root,matches,level):
# root = 'BreakStatement'
logging.info(root)
port = REDIS_PORT
# if isfile(clusterPath +"/"+root+".pickle"):
# return load_zipped_pickle(clusterPath +"/"+root+".pickle")
# else:
# redis_db = redis.StrictRedis(host="localhost", port=port, db=1) #L1
if level == 'tokens':
redis_db = redis.StrictRedis(host="localhost", port=port, db=3)
else:
redis_db = redis.StrictRedis(host="localhost", port=port, db=2)
keys = redis_db.scan(0, match=root+'-*', count='100000000')
matches = matches[matches.pairs_key.apply(lambda x: x.startswith(root + '-'))]
# keys = redis_db.hkeys("dump")
# tuples = []
@@ -75,8 +73,7 @@ def loadPairMulti(root,clusterPath,level):
# coreNumber = 1600
# print('Core number %s' % coreNumber)
matches = pd.DataFrame(keys[1],columns=['pairs_key'])
matches['pairs_key']=matches['pairs_key'].apply(lambda x:x.decode())
# matches['pairs']=matches['pairs_key'].apply(lambda x:x.split('_')[1:])
matches['pairs']=matches['pairs_key'].apply(lambda x:x.split(root)[1].split('/')[1:])
matches['tuples'] = matches.pairs.apply(lambda x: tuple(x))
@@ -116,10 +113,20 @@ def cluster(clusterPath,pairsPath, level):
os.makedirs(clusterPath, exist_ok=True)
roots = listdir(pairsPath)
roots = [i for i in roots if not i.startswith('.')]
port = REDIS_PORT
if level == 'tokens':
redis_db = redis.StrictRedis(host="localhost", port=port, db=3)
else:
redis_db = redis.StrictRedis(host="localhost", port=port, db=2)
keys = redis_db.hkeys("compared")
compared = pd.DataFrame(keys, columns=['pairs_key'])
compared['pairs_key'] = compared['pairs_key'].apply(lambda x: x.decode())
# roots = [rootType]
# parallelRun(loadPairMulti,roots,clusterPath)
for root in roots:
matches = loadPairMulti(root,clusterPath,level)
matches = loadPairMulti(root,compared,level)
sizes = matches['sizes'].unique().tolist()
for s in sizes:
match = matches[matches['sizes'] == s]