test
This commit is contained in:
@@ -215,89 +215,89 @@ public class AkkaTreeLoader {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void coreCompare(String name , String inputPath, String innerPort) {
|
// private static void coreCompare(String name , String inputPath, String innerPort) {
|
||||||
JedisPool pool = new JedisPool(new JedisPoolConfig(), "127.0.0.1", Integer.valueOf(innerPort), 20000000);
|
// JedisPool pool = new JedisPool(new JedisPoolConfig(), "127.0.0.1", Integer.valueOf(innerPort), 20000000);
|
||||||
Map<String, String> resultMap;
|
// Map<String, String> resultMap;
|
||||||
try (Jedis jedis = pool.getResource()) {
|
// try (Jedis jedis = pool.getResource()) {
|
||||||
resultMap = jedis.hgetAll(name);
|
// resultMap = jedis.hgetAll(name);
|
||||||
}
|
// }
|
||||||
String[] split = name.split("_");
|
// String[] split = name.split("_");
|
||||||
|
//
|
||||||
|
//
|
||||||
String i = split[1];
|
// String i = split[1];
|
||||||
String j = split[2];
|
// String j = split[2];
|
||||||
String firstValue = resultMap.get("0");
|
// String firstValue = resultMap.get("0");
|
||||||
String secondValue = resultMap.get("1");
|
// String secondValue = resultMap.get("1");
|
||||||
|
//
|
||||||
String[] firstValueSplit = firstValue.split("GumTreeOutput2");
|
// String[] firstValueSplit = firstValue.split("GumTreeOutput2");
|
||||||
String[] secondValueSplit = secondValue.split("GumTreeOutput2");
|
// String[] secondValueSplit = secondValue.split("GumTreeOutput2");
|
||||||
|
//
|
||||||
if (firstValueSplit.length == 1) {
|
// if (firstValueSplit.length == 1) {
|
||||||
firstValue = inputPath + firstValueSplit[0];
|
// firstValue = inputPath + firstValueSplit[0];
|
||||||
} else {
|
// } else {
|
||||||
firstValue = inputPath + firstValueSplit[1];
|
// firstValue = inputPath + firstValueSplit[1];
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (secondValueSplit.length == 1) {
|
// if (secondValueSplit.length == 1) {
|
||||||
secondValue = inputPath + secondValueSplit[0];
|
// secondValue = inputPath + secondValueSplit[0];
|
||||||
} else {
|
// } else {
|
||||||
secondValue = inputPath + secondValueSplit[1];
|
// secondValue = inputPath + secondValueSplit[1];
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
ITree oldTree = getSimpliedTree(firstValue);
|
// ITree oldTree = getSimpliedTree(firstValue);
|
||||||
|
//
|
||||||
ITree newTree = getSimpliedTree(secondValue);
|
// ITree newTree = getSimpliedTree(secondValue);
|
||||||
|
//
|
||||||
Matcher m = Matchers.getInstance().getMatcher(oldTree, newTree);
|
// Matcher m = Matchers.getInstance().getMatcher(oldTree, newTree);
|
||||||
m.match();
|
// m.match();
|
||||||
|
//
|
||||||
|
//
|
||||||
ActionGenerator ag = new ActionGenerator(oldTree, newTree, m.getMappings());
|
// ActionGenerator ag = new ActionGenerator(oldTree, newTree, m.getMappings());
|
||||||
ag.generate();
|
// ag.generate();
|
||||||
List<Action> actions = ag.getActions();
|
// List<Action> actions = ag.getActions();
|
||||||
|
//
|
||||||
double chawatheSimilarity1 = m.chawatheSimilarity(oldTree, newTree);
|
// double chawatheSimilarity1 = m.chawatheSimilarity(oldTree, newTree);
|
||||||
String chawatheSimilarity = String.format("%1.2f", chawatheSimilarity1);
|
// String chawatheSimilarity = String.format("%1.2f", chawatheSimilarity1);
|
||||||
double diceSimilarity1 = m.diceSimilarity(oldTree, newTree);
|
// double diceSimilarity1 = m.diceSimilarity(oldTree, newTree);
|
||||||
String diceSimilarity = String.format("%1.2f", diceSimilarity1);
|
// String diceSimilarity = String.format("%1.2f", diceSimilarity1);
|
||||||
double jaccardSimilarity1 = m.jaccardSimilarity(oldTree, newTree);
|
// double jaccardSimilarity1 = m.jaccardSimilarity(oldTree, newTree);
|
||||||
String jaccardSimilarity = String.format("%1.2f", jaccardSimilarity1);
|
// String jaccardSimilarity = String.format("%1.2f", jaccardSimilarity1);
|
||||||
|
//
|
||||||
String editDistance = String.valueOf(actions.size());
|
// String editDistance = String.valueOf(actions.size());
|
||||||
|
//
|
||||||
String result = resultMap.get("0") + "," + resultMap.get("1") + "," + chawatheSimilarity + "," + diceSimilarity + "," + jaccardSimilarity + "," + editDistance;
|
// String result = resultMap.get("0") + "," + resultMap.get("1") + "," + chawatheSimilarity + "," + diceSimilarity + "," + jaccardSimilarity + "," + editDistance;
|
||||||
|
//
|
||||||
|
//
|
||||||
if (((Double) chawatheSimilarity1).equals(1.0) || ((Double) diceSimilarity1).equals(1.0)
|
// if (((Double) chawatheSimilarity1).equals(1.0) || ((Double) diceSimilarity1).equals(1.0)
|
||||||
|| ((Double) jaccardSimilarity1).equals(1.0) || actions.size() == 0) {
|
// || ((Double) jaccardSimilarity1).equals(1.0) || actions.size() == 0) {
|
||||||
String matchKey = "match_" + (String.valueOf(i)) + "_" + String.valueOf(j);
|
// String matchKey = "match_" + (String.valueOf(i)) + "_" + String.valueOf(j);
|
||||||
|
//
|
||||||
try (Jedis jedis = pool.getResource()) {
|
// try (Jedis jedis = pool.getResource()) {
|
||||||
jedis.select(1);
|
// jedis.select(1);
|
||||||
jedis.set(matchKey, result);
|
// jedis.set(matchKey, result);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
try (Jedis jedis = pool.getResource()) {
|
// try (Jedis jedis = pool.getResource()) {
|
||||||
jedis.del("pair_"+ (String.valueOf(i)) + "_" + String.valueOf(j));
|
// jedis.del("pair_"+ (String.valueOf(i)) + "_" + String.valueOf(j));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
}catch (Exception e){
|
// }catch (Exception e){
|
||||||
log.error(e.toString() + " {}",(name));
|
// log.error(e.toString() + " {}",(name));
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -324,17 +324,17 @@ public class AkkaTreeLoader {
|
|||||||
readMessageFiles(fileToCompare,port);
|
readMessageFiles(fileToCompare,port);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void processMessages(String inputPath, String outputPath) {
|
// public static void processMessages(String inputPath, String outputPath) {
|
||||||
File folder = new File(outputPath + "pairs_splitted/");
|
// File folder = new File(outputPath + "pairs_splitted/");
|
||||||
File[] listOfFiles = folder.listFiles();
|
// File[] listOfFiles = folder.listFiles();
|
||||||
Stream<File> stream = Arrays.stream(listOfFiles);
|
// Stream<File> stream = Arrays.stream(listOfFiles);
|
||||||
List<File> pjs = stream
|
// List<File> pjs = stream
|
||||||
.filter(x -> !x.getName().startsWith("."))
|
// .filter(x -> !x.getName().startsWith("."))
|
||||||
.collect(Collectors.toList());
|
// .collect(Collectors.toList());
|
||||||
FileHelper.createDirectory(outputPath + "comparison_splitted/");
|
// FileHelper.createDirectory(outputPath + "comparison_splitted/");
|
||||||
pjs.parallelStream()
|
// pjs.parallelStream()
|
||||||
.forEach(m -> coreLoop(m, outputPath,inputPath));
|
// .forEach(m -> coreLoop(m, outputPath,inputPath));
|
||||||
}
|
// }
|
||||||
|
|
||||||
/** Read the object from Base64 string. */
|
/** Read the object from Base64 string. */
|
||||||
private static Object fromString( String s ) throws IOException ,
|
private static Object fromString( String s ) throws IOException ,
|
||||||
@@ -346,8 +346,8 @@ public class AkkaTreeLoader {
|
|||||||
ois.close();
|
ois.close();
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
public static ITree getSimpliedTree(String fn) {
|
public static ITree getSimpliedTree(String fn,JedisPoolConfig config) {
|
||||||
JedisPool pool = new JedisPool(new JedisPoolConfig(), "127.0.0.1", Integer.valueOf(6399), 20000000);
|
JedisPool pool = new JedisPool(config, "127.0.0.1", Integer.valueOf(6399), 20000000);
|
||||||
HierarchicalActionSet actionSet = null;
|
HierarchicalActionSet actionSet = null;
|
||||||
try (Jedis inner = pool.getResource()) {
|
try (Jedis inner = pool.getResource()) {
|
||||||
String s = inner.get(fn.substring(1));
|
String s = inner.get(fn.substring(1));
|
||||||
@@ -470,69 +470,69 @@ public class AkkaTreeLoader {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static void coreLoop(File mes, String outputPath,String inputPath) {
|
// private static void coreLoop(File mes, String outputPath,String inputPath) {
|
||||||
try {
|
// try {
|
||||||
|
//
|
||||||
log.info("Starting in coreLoop");
|
// log.info("Starting in coreLoop");
|
||||||
|
//
|
||||||
BufferedReader br = null;
|
// BufferedReader br = null;
|
||||||
String sCurrentLine = null;
|
// String sCurrentLine = null;
|
||||||
BufferedWriter writer = new BufferedWriter(new FileWriter(outputPath + "comparison_splitted/" + "output_" + mes.getName()));
|
// BufferedWriter writer = new BufferedWriter(new FileWriter(outputPath + "comparison_splitted/" + "output_" + mes.getName()));
|
||||||
|
//
|
||||||
br = new BufferedReader(
|
// br = new BufferedReader(
|
||||||
new FileReader(mes));
|
// new FileReader(mes));
|
||||||
while ((sCurrentLine = br.readLine()) != null) {
|
// while ((sCurrentLine = br.readLine()) != null) {
|
||||||
String currentLine = sCurrentLine;
|
// String currentLine = sCurrentLine;
|
||||||
String[] split = currentLine.split("\t");
|
// String[] split = currentLine.split("\t");
|
||||||
String i = split[0];
|
// String i = split[0];
|
||||||
String j = split[1];
|
// String j = split[1];
|
||||||
String firstValue = split[2];
|
// String firstValue = split[2];
|
||||||
String secondValue = split[3];
|
// String secondValue = split[3];
|
||||||
|
//
|
||||||
firstValue = inputPath + firstValue.split("GumTreeOutput2")[1];
|
// firstValue = inputPath + firstValue.split("GumTreeOutput2")[1];
|
||||||
secondValue = inputPath + secondValue.split("GumTreeOutput2")[1];
|
// secondValue = inputPath + secondValue.split("GumTreeOutput2")[1];
|
||||||
|
//
|
||||||
ITree oldTree = getSimpliedTree(firstValue);
|
// ITree oldTree = getSimpliedTree(firstValue);
|
||||||
|
//
|
||||||
ITree newTree = getSimpliedTree(secondValue);
|
// ITree newTree = getSimpliedTree(secondValue);
|
||||||
|
//
|
||||||
Matcher m = Matchers.getInstance().getMatcher(oldTree, newTree);
|
// Matcher m = Matchers.getInstance().getMatcher(oldTree, newTree);
|
||||||
m.match();
|
// m.match();
|
||||||
|
//
|
||||||
ActionGenerator ag = new ActionGenerator(oldTree, newTree, m.getMappings());
|
// ActionGenerator ag = new ActionGenerator(oldTree, newTree, m.getMappings());
|
||||||
ag.generate();
|
// ag.generate();
|
||||||
List<Action> actions = ag.getActions();
|
// List<Action> actions = ag.getActions();
|
||||||
writer.write(String.valueOf(i));
|
// writer.write(String.valueOf(i));
|
||||||
writer.write("\t");
|
// writer.write("\t");
|
||||||
writer.write(String.valueOf(j));
|
// writer.write(String.valueOf(j));
|
||||||
writer.write("\t");
|
// writer.write("\t");
|
||||||
|
//
|
||||||
writer.write(String.format("%1.2f", m.chawatheSimilarity(oldTree, newTree)));
|
// writer.write(String.format("%1.2f", m.chawatheSimilarity(oldTree, newTree)));
|
||||||
writer.write("\t");
|
// writer.write("\t");
|
||||||
writer.write(String.format("%1.2f", m.diceSimilarity(oldTree, newTree)));
|
// writer.write(String.format("%1.2f", m.diceSimilarity(oldTree, newTree)));
|
||||||
writer.write("\t");
|
// writer.write("\t");
|
||||||
writer.write(String.format("%1.2f", m.jaccardSimilarity(oldTree, newTree)));
|
// writer.write(String.format("%1.2f", m.jaccardSimilarity(oldTree, newTree)));
|
||||||
writer.write("\t");
|
// writer.write("\t");
|
||||||
writer.write(String.valueOf(actions.size()));
|
// writer.write(String.valueOf(actions.size()));
|
||||||
writer.write("\t");
|
// writer.write("\t");
|
||||||
writer.write(firstValue);
|
// writer.write(firstValue);
|
||||||
writer.write("\t");
|
// writer.write("\t");
|
||||||
writer.write(secondValue);
|
// writer.write(secondValue);
|
||||||
writer.write("\n");
|
// writer.write("\n");
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
writer.close();
|
// writer.close();
|
||||||
} catch (FileNotFoundException e) {
|
// } catch (FileNotFoundException e) {
|
||||||
log.error("File not found");
|
// log.error("File not found");
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
log.error("Error initializing stream");
|
// log.error("Error initializing stream");
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
log.info("Completed output_" + mes.getName());
|
// log.info("Completed output_" + mes.getName());
|
||||||
}
|
// }
|
||||||
|
|
||||||
private static void readMessageFiles(List<File> folders,String port) {
|
private static void readMessageFiles(List<File> folders,String port) {
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import redis.clients.jedis.Jedis;
|
|||||||
import redis.clients.jedis.JedisPool;
|
import redis.clients.jedis.JedisPool;
|
||||||
import redis.clients.jedis.JedisPoolConfig;
|
import redis.clients.jedis.JedisPoolConfig;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -22,9 +23,13 @@ import static edu.lu.uni.serval.FixPatternParser.violations.AkkaTreeLoader.getSi
|
|||||||
public class Compare {
|
public class Compare {
|
||||||
|
|
||||||
private Logger log = LoggerFactory.getLogger(Compare.class);
|
private Logger log = LoggerFactory.getLogger(Compare.class);
|
||||||
|
private JedisPoolConfig poolConfig;
|
||||||
|
public Compare(JedisPoolConfig pool) {
|
||||||
|
this.poolConfig = pool;
|
||||||
|
}
|
||||||
|
|
||||||
public void coreCompare(String name , String inputPath, String innerPort) {
|
public void coreCompare(String name , String inputPath, String innerPort) {
|
||||||
JedisPool pool = new JedisPool(new JedisPoolConfig(), "127.0.0.1", Integer.valueOf(innerPort), 20000000);
|
JedisPool pool = new JedisPool(poolConfig, "127.0.0.1", Integer.valueOf(innerPort), 20000000);
|
||||||
Map<String, String> resultMap;
|
Map<String, String> resultMap;
|
||||||
try (Jedis jedis = pool.getResource()) {
|
try (Jedis jedis = pool.getResource()) {
|
||||||
resultMap = jedis.hgetAll(name);
|
resultMap = jedis.hgetAll(name);
|
||||||
@@ -53,11 +58,11 @@ public class Compare {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log.info("start simplied tree");
|
|
||||||
ITree oldTree = getSimpliedTree(firstValue);
|
ITree oldTree = getSimpliedTree(firstValue,poolConfig);
|
||||||
log.info("start simplied2 tree");
|
|
||||||
ITree newTree = getSimpliedTree(secondValue);
|
ITree newTree = getSimpliedTree(secondValue,poolConfig);
|
||||||
log.info("start matcher");
|
|
||||||
Matcher m = Matchers.getInstance().getMatcher(oldTree, newTree);
|
Matcher m = Matchers.getInstance().getMatcher(oldTree, newTree);
|
||||||
m.match();
|
m.match();
|
||||||
|
|
||||||
@@ -72,7 +77,7 @@ public class Compare {
|
|||||||
String diceSimilarity = String.format("%1.2f", diceSimilarity1);
|
String diceSimilarity = String.format("%1.2f", diceSimilarity1);
|
||||||
double jaccardSimilarity1 = m.jaccardSimilarity(oldTree, newTree);
|
double jaccardSimilarity1 = m.jaccardSimilarity(oldTree, newTree);
|
||||||
String jaccardSimilarity = String.format("%1.2f", jaccardSimilarity1);
|
String jaccardSimilarity = String.format("%1.2f", jaccardSimilarity1);
|
||||||
log.info("end simi");
|
|
||||||
String editDistance = String.valueOf(actions.size());
|
String editDistance = String.valueOf(actions.size());
|
||||||
|
|
||||||
String result = resultMap.get("0") + "," + resultMap.get("1") + "," + chawatheSimilarity + "," + diceSimilarity + "," + jaccardSimilarity + "," + editDistance;
|
String result = resultMap.get("0") + "," + resultMap.get("1") + "," + chawatheSimilarity + "," + diceSimilarity + "," + jaccardSimilarity + "," + editDistance;
|
||||||
@@ -100,4 +105,6 @@ public class Compare {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import java.io.BufferedReader;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
import java.time.Duration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
@@ -76,7 +77,7 @@ public class TreeWorker extends UntypedActor {
|
|||||||
//
|
//
|
||||||
final ExecutorService executor = Executors.newSingleThreadExecutor();
|
final ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
// // schedule the work
|
// // schedule the work
|
||||||
final Future<?> future = executor.submit(new RunnableCompare(name, inputPath, innerPort, new Compare()));
|
final Future<?> future = executor.submit(new RunnableCompare(name, inputPath, innerPort, new Compare(poolConfig)));
|
||||||
try {
|
try {
|
||||||
// wait for task to complete
|
// wait for task to complete
|
||||||
future.get(Configuration.SECONDS_TO_WAIT, TimeUnit.SECONDS);
|
future.get(Configuration.SECONDS_TO_WAIT, TimeUnit.SECONDS);
|
||||||
@@ -174,6 +175,25 @@ public class TreeWorker extends UntypedActor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static final JedisPoolConfig poolConfig = buildPoolConfig();
|
||||||
|
|
||||||
|
|
||||||
|
private static JedisPoolConfig buildPoolConfig() {
|
||||||
|
final JedisPoolConfig poolConfig = new JedisPoolConfig();
|
||||||
|
poolConfig.setMaxTotal(128);
|
||||||
|
poolConfig.setMaxIdle(128);
|
||||||
|
poolConfig.setMinIdle(16);
|
||||||
|
poolConfig.setTestOnBorrow(true);
|
||||||
|
poolConfig.setTestOnReturn(true);
|
||||||
|
poolConfig.setTestWhileIdle(true);
|
||||||
|
poolConfig.setMinEvictableIdleTimeMillis(Duration.ofMinutes(60).toMillis());
|
||||||
|
poolConfig.setTimeBetweenEvictionRunsMillis(Duration.ofHours(30).toMillis());
|
||||||
|
poolConfig.setNumTestsPerEvictionRun(3);
|
||||||
|
poolConfig.setBlockWhenExhausted(true);
|
||||||
|
|
||||||
|
return poolConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user