This commit is contained in:
Anil Koyuncu
2018-04-04 21:51:15 +02:00
parent 5c27c2c87b
commit a28043bf2c
2 changed files with 40 additions and 62 deletions
@@ -354,39 +354,27 @@ public class AkkaTreeLoader {
}
public static ITree getSimpliedTree(String fn,JedisPoolConfig config) {
JedisPool pool = new JedisPool(config, "127.0.0.1", Integer.valueOf(6399), 20000000);
HierarchicalActionSet actionSet = null;
try (Jedis inner = pool.getResource()) {
ITree tree = null;
Jedis inner = null;
try {
inner = pool.getResource();
String s = inner.get(fn.substring(1));
actionSet = (HierarchicalActionSet) fromString(s);
HierarchicalActionSet actionSet = (HierarchicalActionSet) fromString(s);
ITree parent = null;
ITree children =null;
tree = getASTTree(actionSet, parent, children);
tree.setParent(null);
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}finally {
if (inner != null) {
inner.close();
}
}
// try {
// FileInputStream fi = new FileInputStream(new File(fn));
// ObjectInputStream oi = new ObjectInputStream(fi);
// actionSet = (HierarchicalActionSet) oi.readObject();
// oi.close();
// fi.close();
//
//
// } catch (FileNotFoundException e) {
// log.error("File not found");
// e.printStackTrace();
// } catch (IOException e) {
// log.error("Error initializing stream");
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
ITree parent = null;
ITree children =null;
ITree tree = getASTTree(actionSet, parent, children);
tree.setParent(null);
return tree;
}
@@ -637,12 +625,12 @@ public class AkkaTreeLoader {
poolConfig.setMaxTotal(128);
poolConfig.setMaxIdle(128);
poolConfig.setMinIdle(16);
poolConfig.setTestOnBorrow(true);
poolConfig.setTestOnReturn(true);
poolConfig.setTestOnBorrow(false);
poolConfig.setTestOnReturn(false);
poolConfig.setTestWhileIdle(true);
poolConfig.setMinEvictableIdleTimeMillis(Duration.ofMinutes(60).toMillis());
poolConfig.setTimeBetweenEvictionRunsMillis(Duration.ofHours(30).toMillis());
poolConfig.setNumTestsPerEvictionRun(3);
// poolConfig.setNumTestsPerEvictionRun(3);
poolConfig.setBlockWhenExhausted(true);
return poolConfig;
@@ -31,9 +31,12 @@ public class Compare {
public void coreCompare(String name , String inputPath, String innerPort) {
JedisPool pool = new JedisPool(poolConfig, "127.0.0.1", Integer.valueOf(innerPort), 20000000);
Map<String, String> resultMap;
try (Jedis jedis = pool.getResource()) {
Jedis jedis = null;
try {
jedis = pool.getResource();
resultMap = jedis.hgetAll(name);
}
String[] split = name.split("_");
@@ -42,23 +45,6 @@ public class Compare {
String firstValue = resultMap.get("0");
String secondValue = resultMap.get("1");
// String[] firstValueSplit = firstValue.split("GumTreeOutput2");
// String[] secondValueSplit = secondValue.split("GumTreeOutput2");
//
// if (firstValueSplit.length == 1) {
// firstValue = inputPath + firstValueSplit[0];
// } else {
// firstValue = inputPath + firstValueSplit[1];
// }
//
// if (secondValueSplit.length == 1) {
// secondValue = inputPath + secondValueSplit[0];
// } else {
// secondValue = inputPath + secondValueSplit[1];
// }
try {
ITree oldTree = getSimpliedTree(firstValue,poolConfig);
ITree newTree = getSimpliedTree(secondValue,poolConfig);
@@ -87,22 +73,26 @@ public class Compare {
|| ((Double) jaccardSimilarity1).equals(1.0) || actions.size() == 0) {
String matchKey = "match_" + (String.valueOf(i)) + "_" + String.valueOf(j);
log.info(matchKey);
try (Jedis jedis = pool.getResource()) {
jedis.select(1);
jedis.set(matchKey, result);
}
}
try (Jedis jedis = pool.getResource()) {
jedis.del("pair_" + (String.valueOf(i)) + "_" + String.valueOf(j));
}
} catch (Exception e) {
log.error(e.toString() + " {}", (name));
}finally {
if (jedis != null) {
jedis.close();
}
}
}