From b5b57e9ba81e5ec6e9f0629c074548787c531419 Mon Sep 17 00:00:00 2001 From: fixminer Date: Sun, 16 Aug 2020 00:29:05 +0200 Subject: [PATCH] NEW: compare without target tree and use hset to store the compared index --- python/abstractPatch.py | 27 ++++++++++++------- .../serval/richedit/jobs/CompareTrees.java | 11 +++++--- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/python/abstractPatch.py b/python/abstractPatch.py index 73df327..c6b7a99 100644 --- a/python/abstractPatch.py +++ b/python/abstractPatch.py @@ -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] diff --git a/richedit/src/main/java/edu/lu/uni/serval/richedit/jobs/CompareTrees.java b/richedit/src/main/java/edu/lu/uni/serval/richedit/jobs/CompareTrees.java index 79770bb..1c2254c 100755 --- a/richedit/src/main/java/edu/lu/uni/serval/richedit/jobs/CompareTrees.java +++ b/richedit/src/main/java/edu/lu/uni/serval/richedit/jobs/CompareTrees.java @@ -190,14 +190,16 @@ public class CompareTrees { if (oldShapeTree.equals(newShapeTree)) { if (oldActionTree.equals(newActionTree)) { - if (oldTargetTree.equals(newTargetTree)) { +// if (oldTargetTree.equals(newTargetTree)) { // samePairs.add(matchKey); try (Jedis jedis = outerPool.getResource()) { //// jedis.del(matchKey); jedis.select(2); - jedis.set(matchKey, "1"); + + jedis.hset("compared", matchKey, "1"); +// jedis.set(matchKey, "1"); } - } +// } } } return true; @@ -225,7 +227,8 @@ public class CompareTrees { if (retval >= 0) { try (Jedis jedis = outerPool.getResource()) { jedis.select(3); - jedis.set(matchKey, "1"); + jedis.hset("compared", matchKey, "1"); +// jedis.set(matchKey, "1"); } }