NEW: compare without target tree and use hset to store the compared index
This commit is contained in:
+17
-10
@@ -52,20 +52,18 @@ delPattern = 'DEL (' + '|'.join(ast) + ')@@(.*)@AT@'
|
|||||||
insPattern = 'INS (' + '|'.join(ast) + ')@@(.*)@TO@ (' + '|'.join(ast) + ')@@(.*)@AT@'
|
insPattern = 'INS (' + '|'.join(ast) + ')@@(.*)@TO@ (' + '|'.join(ast) + ')@@(.*)@AT@'
|
||||||
updPattern = 'UPD (' + '|'.join(ast) + ')@@(.*)@TO@(.*)@AT@'
|
updPattern = 'UPD (' + '|'.join(ast) + ')@@(.*)@TO@(.*)@AT@'
|
||||||
|
|
||||||
def loadPairMulti(root,clusterPath,level):
|
def loadPairMulti(root,matches,level):
|
||||||
|
|
||||||
# root = 'BreakStatement'
|
# root = 'BreakStatement'
|
||||||
logging.info(root)
|
logging.info(root)
|
||||||
port = REDIS_PORT
|
|
||||||
# if isfile(clusterPath +"/"+root+".pickle"):
|
# if isfile(clusterPath +"/"+root+".pickle"):
|
||||||
# return load_zipped_pickle(clusterPath +"/"+root+".pickle")
|
# return load_zipped_pickle(clusterPath +"/"+root+".pickle")
|
||||||
# else:
|
# else:
|
||||||
# redis_db = redis.StrictRedis(host="localhost", port=port, db=1) #L1
|
# 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:
|
matches = matches[matches.pairs_key.apply(lambda x: x.startswith(root + '-'))]
|
||||||
redis_db = redis.StrictRedis(host="localhost", port=port, db=2)
|
|
||||||
keys = redis_db.scan(0, match=root+'-*', count='100000000')
|
|
||||||
# keys = redis_db.hkeys("dump")
|
# keys = redis_db.hkeys("dump")
|
||||||
|
|
||||||
# tuples = []
|
# tuples = []
|
||||||
@@ -75,8 +73,7 @@ def loadPairMulti(root,clusterPath,level):
|
|||||||
|
|
||||||
# coreNumber = 1600
|
# coreNumber = 1600
|
||||||
# print('Core number %s' % coreNumber)
|
# 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('_')[1:])
|
||||||
matches['pairs']=matches['pairs_key'].apply(lambda x:x.split(root)[1].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))
|
matches['tuples'] = matches.pairs.apply(lambda x: tuple(x))
|
||||||
@@ -116,10 +113,20 @@ def cluster(clusterPath,pairsPath, level):
|
|||||||
os.makedirs(clusterPath, exist_ok=True)
|
os.makedirs(clusterPath, exist_ok=True)
|
||||||
roots = listdir(pairsPath)
|
roots = listdir(pairsPath)
|
||||||
roots = [i for i in roots if not i.startswith('.')]
|
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]
|
# roots = [rootType]
|
||||||
# parallelRun(loadPairMulti,roots,clusterPath)
|
# parallelRun(loadPairMulti,roots,clusterPath)
|
||||||
for root in roots:
|
for root in roots:
|
||||||
matches = loadPairMulti(root,clusterPath,level)
|
matches = loadPairMulti(root,compared,level)
|
||||||
sizes = matches['sizes'].unique().tolist()
|
sizes = matches['sizes'].unique().tolist()
|
||||||
for s in sizes:
|
for s in sizes:
|
||||||
match = matches[matches['sizes'] == s]
|
match = matches[matches['sizes'] == s]
|
||||||
|
|||||||
@@ -190,14 +190,16 @@ public class CompareTrees {
|
|||||||
|
|
||||||
if (oldShapeTree.equals(newShapeTree)) {
|
if (oldShapeTree.equals(newShapeTree)) {
|
||||||
if (oldActionTree.equals(newActionTree)) {
|
if (oldActionTree.equals(newActionTree)) {
|
||||||
if (oldTargetTree.equals(newTargetTree)) {
|
// if (oldTargetTree.equals(newTargetTree)) {
|
||||||
// samePairs.add(matchKey);
|
// samePairs.add(matchKey);
|
||||||
try (Jedis jedis = outerPool.getResource()) {
|
try (Jedis jedis = outerPool.getResource()) {
|
||||||
//// jedis.del(matchKey);
|
//// jedis.del(matchKey);
|
||||||
jedis.select(2);
|
jedis.select(2);
|
||||||
jedis.set(matchKey, "1");
|
|
||||||
|
jedis.hset("compared", matchKey, "1");
|
||||||
|
// jedis.set(matchKey, "1");
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -225,7 +227,8 @@ public class CompareTrees {
|
|||||||
if (retval >= 0) {
|
if (retval >= 0) {
|
||||||
try (Jedis jedis = outerPool.getResource()) {
|
try (Jedis jedis = outerPool.getResource()) {
|
||||||
jedis.select(3);
|
jedis.select(3);
|
||||||
jedis.set(matchKey, "1");
|
jedis.hset("compared", matchKey, "1");
|
||||||
|
// jedis.set(matchKey, "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user