latest change
This commit is contained in:
@@ -138,6 +138,18 @@
|
|||||||
<version>2.4</version>
|
<version>2.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.redisson</groupId>
|
||||||
|
<artifactId>redisson</artifactId>
|
||||||
|
<version>3.3.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-util</artifactId>
|
||||||
|
<version>9.4.4.v20170414</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@@ -180,3 +192,8 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
<!--edu.lu.uni.serval.fixminer.Launcher
|
||||||
|
edu.lu.uni.serval.fixminer.akka.compare.CompareTrees
|
||||||
|
edu.lu.uni.serval.utils.ClusterToPattern
|
||||||
|
-->
|
||||||
|
|||||||
Regular → Executable
+1
@@ -71,6 +71,7 @@ public class Launcher {
|
|||||||
pairsPath = datasetPath + "/pairs";
|
pairsPath = datasetPath + "/pairs";
|
||||||
dumpsName = "dumps-"+pjName+".rdb";
|
dumpsName = "dumps-"+pjName+".rdb";
|
||||||
int iCursor = Integer.valueOf(cursor);
|
int iCursor = Integer.valueOf(cursor);
|
||||||
|
// jobType = "CACHE";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
switch (jobType) {
|
switch (jobType) {
|
||||||
|
|||||||
Regular → Executable
+2
-1
@@ -22,7 +22,8 @@ public class TestTreeLoader {
|
|||||||
|
|
||||||
|
|
||||||
// String inputPath = "/Users/anilkoyuncu/bugStudy/dataset/GumTreeOutput/ENTESB/ASTDumps";
|
// String inputPath = "/Users/anilkoyuncu/bugStudy/dataset/GumTreeOutput/ENTESB/ASTDumps";
|
||||||
String inputPath = "/Users/anilkoyuncu/bugStudy/dataset/GumTreeOutput2/";
|
// String inputPath = "/Users/anilkoyuncu/bugStudy/dataset/GumTreeOutput2/";
|
||||||
|
String inputPath ="/Users/anil.koyuncu/projects/fixminer-all/enhancedASTDiff/python/data/EnhancedASTDiffgumInput-old/AssertStatement";
|
||||||
File folder = new File(inputPath);
|
File folder = new File(inputPath);
|
||||||
File[] listOfFiles = folder.listFiles();
|
File[] listOfFiles = folder.listFiles();
|
||||||
Stream<File> stream = Arrays.stream(listOfFiles);
|
Stream<File> stream = Arrays.stream(listOfFiles);
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+192
-175
@@ -23,6 +23,7 @@ import redis.clients.jedis.JedisPool;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static edu.lu.uni.serval.fixminer.jobs.MultiThreadTreeLoaderCluster3.getNames;
|
import static edu.lu.uni.serval.fixminer.jobs.MultiThreadTreeLoaderCluster3.getNames;
|
||||||
|
|
||||||
@@ -52,15 +53,15 @@ public class CompareTrees {
|
|||||||
log.info(cmdInner);
|
log.info(cmdInner);
|
||||||
cs.runShell(cmdInner, portInner);
|
cs.runShell(cmdInner, portInner);
|
||||||
|
|
||||||
String numOfWorkers = args[4];
|
String numOfWorkers = "100000000";//args[4];
|
||||||
String host = args[5];
|
String host = "localhost";//args[5];
|
||||||
// -Djava.util.concurrent.ForkJoinPool.common.parallelism=256
|
// -Djava.util.concurrent.ForkJoinPool.common.parallelism=256
|
||||||
|
|
||||||
final JedisPool innerPool = new JedisPool(PoolBuilder.getPoolConfig(), host,Integer.valueOf(portInner),20000000);
|
final JedisPool innerPool = new JedisPool(PoolBuilder.getPoolConfig(), host,Integer.valueOf(portInner),20000000);
|
||||||
|
|
||||||
final JedisPool outerPool = new JedisPool(PoolBuilder.getPoolConfig(), host,Integer.valueOf(port),20000000);
|
final JedisPool outerPool = new JedisPool(PoolBuilder.getPoolConfig(), host,Integer.valueOf(port),20000000);
|
||||||
|
|
||||||
List<String> listOfPairs = AkkaTreeParser.getRMessages(innerPool,Integer.valueOf(numOfWorkers));
|
List<String> listOfPairs = AkkaTreeParser.getMessages(innerPool,Integer.valueOf(numOfWorkers));
|
||||||
|
|
||||||
// String pair = AkkaTreeParser.getMessage(innerPool);
|
// String pair = AkkaTreeParser.getMessage(innerPool);
|
||||||
|
|
||||||
@@ -90,8 +91,29 @@ public class CompareTrees {
|
|||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
ArrayList<String> samePairs = new ArrayList<>();
|
||||||
|
ArrayList<String> errorPairs = new ArrayList<>();
|
||||||
|
|
||||||
listOfPairs.stream().parallel().forEach(m->coreCompare(m, args[0],innerPool, outerPool));
|
|
||||||
|
|
||||||
|
listOfPairs.stream().parallel().forEach(m->coreCompare(m, args[0],innerPool, outerPool,samePairs,errorPairs));
|
||||||
|
|
||||||
|
// int size = samePairs.size();
|
||||||
|
try (Jedis jedis = innerPool.getResource()) {
|
||||||
|
// jedis.select(2);
|
||||||
|
// for (String samePair : samePairs) {
|
||||||
|
// jedis.set(samePair,"1");
|
||||||
|
// }
|
||||||
|
|
||||||
|
jedis.select(0);
|
||||||
|
jedis.flushDB();
|
||||||
|
for (String errorPair : errorPairs) {
|
||||||
|
jedis.hset(errorPair, "0", "1");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
log.info("End process");
|
||||||
// listOfPairs.parallelStream().forEach(m->coreCompare(m, args[0],innerPool, outerPool));
|
// listOfPairs.parallelStream().forEach(m->coreCompare(m, args[0],innerPool, outerPool));
|
||||||
|
|
||||||
// for (String listOfPair : listOfPairs) {
|
// for (String listOfPair : listOfPairs) {
|
||||||
@@ -119,200 +141,195 @@ public class CompareTrees {
|
|||||||
// }.counter;
|
// }.counter;
|
||||||
// coreCompare(args[0],args[1],args[2],args[3]);
|
// coreCompare(args[0],args[1],args[2],args[3]);
|
||||||
}
|
}
|
||||||
public static void coreCompare(String pairName, String treeType,JedisPool innerPool,JedisPool outerPool ) {
|
public static void coreCompare(String pairName, String treeType,JedisPool innerPool,JedisPool outerPool,ArrayList<String> samePairs,ArrayList<String> errorPairs ) {
|
||||||
|
|
||||||
|
// if (samePairs.size() % 1000 == 0) {
|
||||||
|
// log.info("Same pairs size "+samePairs.size());
|
||||||
|
// }
|
||||||
|
|
||||||
// String portInner = "6380";
|
|
||||||
// String port = "6399";
|
|
||||||
|
|
||||||
// JedisPool innerPool = new JedisPool(PoolBuilder.getPoolConfig(), "127.0.0.1",Integer.valueOf(portInner),20000000);
|
|
||||||
//
|
|
||||||
// JedisPool outerPool = new JedisPool(PoolBuilder.getPoolConfig(), "127.0.0.1",Integer.valueOf(port),20000000);
|
|
||||||
|
|
||||||
Map<String, String> resultMap;
|
|
||||||
Jedis jedis = null;
|
|
||||||
ITree oldTree = null;
|
ITree oldTree = null;
|
||||||
ITree newTree = null;
|
ITree newTree = null;
|
||||||
Pair<ITree, HierarchicalActionSet> oldPair = null;
|
Pair<ITree, HierarchicalActionSet> oldPair = null;
|
||||||
Pair<ITree, HierarchicalActionSet> newPair = null;
|
Pair<ITree, HierarchicalActionSet> newPair = null;
|
||||||
|
String matchKey = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
jedis = innerPool.getResource();
|
|
||||||
|
|
||||||
String[] split = pairName.split("_");
|
String[] split = pairName.split("_");
|
||||||
|
|
||||||
|
|
||||||
String i = split[1];
|
String i = split[1];
|
||||||
String j = split[2];
|
String j = split[2];
|
||||||
String keyName = split[0];
|
String keyName = split[0];
|
||||||
|
matchKey = keyName + "_" + (String.valueOf(i)) + "_" + String.valueOf(j);
|
||||||
|
// jedis.select(0);
|
||||||
|
// Set<String> keys = jedis.keys(matchKey);
|
||||||
|
// if (keys.size() > 0) {
|
||||||
|
// jedis.del(matchKey);
|
||||||
|
// } else {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// jedis.srem("pairs",matchKey);
|
||||||
|
|
||||||
switch (treeType) {
|
switch (treeType) {
|
||||||
case "shape":
|
case "shape":
|
||||||
oldTree = EDiffHelper.getShapes(keyName, i, outerPool,innerPool);
|
oldTree = EDiffHelper.getShapes(keyName, i, outerPool, innerPool);
|
||||||
newTree = EDiffHelper.getShapes(keyName, j, outerPool,innerPool);
|
newTree = EDiffHelper.getShapes(keyName, j, outerPool, innerPool);
|
||||||
break;
|
break;
|
||||||
case "action":
|
case "action":
|
||||||
oldPair = EDiffHelper.getActions(keyName, i, outerPool,innerPool);
|
oldPair = EDiffHelper.getActions(keyName, i, outerPool, innerPool);
|
||||||
newPair = EDiffHelper.getActions(keyName, j, outerPool,innerPool);
|
newPair = EDiffHelper.getActions(keyName, j, outerPool, innerPool);
|
||||||
oldTree = oldPair.getValue0();
|
oldTree = oldPair.getValue0();
|
||||||
newTree = newPair.getValue0();
|
newTree = newPair.getValue0();
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "token":
|
case "token":
|
||||||
oldTree = EDiffHelper.getTokens(keyName, i, outerPool,innerPool);
|
oldTree = EDiffHelper.getTokens(keyName, i, outerPool, innerPool);
|
||||||
newTree = EDiffHelper.getTokens(keyName, j, outerPool,innerPool);
|
newTree = EDiffHelper.getTokens(keyName, j, outerPool, innerPool);
|
||||||
// List<String> oldTokens = new ArrayList<>();
|
|
||||||
// List<String> newTokens = new ArrayList<>();
|
String oldTokens = EDiffHelper.getNames2(oldTree);
|
||||||
|
String newTokens = EDiffHelper.getNames2(newTree);
|
||||||
|
|
||||||
|
JaroWinklerDistance jwd = new JaroWinklerDistance();
|
||||||
|
|
||||||
|
|
||||||
|
Double overallSimi = Double.valueOf(0);
|
||||||
|
|
||||||
|
if (!(oldTokens.trim().isEmpty() || newTokens.trim().isEmpty())) {
|
||||||
|
overallSimi = jwd.apply(oldTokens, newTokens);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
String oldTokens = EDiffHelper.getNames2(oldTree);
|
int retval = Double.compare(overallSimi, Double.valueOf(1));
|
||||||
String newTokens = EDiffHelper.getNames2(newTree);
|
|
||||||
|
|
||||||
|
if (retval >= 0) {
|
||||||
// CharSequence[] oldSequences = oldTokens.toArray(new CharSequence[oldTokens.size()]);
|
String result = i + "," + j + "," + String.join(",", oldTokens);
|
||||||
// CharSequence[] newSequences = newTokens.toArray(new CharSequence[newTokens.size()]);
|
// jedis.select(2);
|
||||||
JaroWinklerDistance jwd = new JaroWinklerDistance();
|
// jedis.set(matchKey, result);
|
||||||
|
try (Jedis jedis = innerPool.getResource()) {
|
||||||
|
// jedis.del(matchKey);
|
||||||
Double overallSimi = Double.valueOf(0);
|
jedis.select(2);
|
||||||
|
jedis.set(matchKey, result);
|
||||||
if (! (oldTokens.trim().isEmpty() || newTokens.trim().isEmpty())){
|
}
|
||||||
overallSimi = jwd.apply(oldTokens, newTokens);
|
// samePairs.add(matchKey);
|
||||||
|
// try (Jedis jedis = innerPool.getResource()) {
|
||||||
}
|
//// jedis.del(matchKey);
|
||||||
// if(oldSequences.length > 0 && (oldSequences.length == newSequences.length)){
|
// jedis.select(2);
|
||||||
// for (int idx = 0; idx < newSequences.length; idx++) {
|
// jedis.set(matchKey, result);
|
||||||
// Double simi = jwd.apply(newSequences[idx], oldSequences[idx]);
|
// }
|
||||||
// overallSimi = simi + overallSimi;
|
}
|
||||||
// }
|
// jedis.select(0);
|
||||||
// overallSimi = overallSimi / oldSequences.length;
|
//// jedis.srem("pairs",matchKey);
|
||||||
// }else{
|
|
||||||
// overallSimi = Double.valueOf(0);
|
|
||||||
//// if(oldSequences.length != 0) {
|
|
||||||
//// log.info("ERROR");
|
|
||||||
//// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
int retval = Double.compare(overallSimi, Double.valueOf(1));
|
|
||||||
String matchKey = keyName+"_" + (String.valueOf(i)) + "_" + String.valueOf(j);
|
|
||||||
if(retval >= 0){
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String result = i + "," + j + ","+String.join(",", oldTokens);
|
|
||||||
jedis.select(2);
|
|
||||||
jedis.set(matchKey, result);
|
|
||||||
}
|
|
||||||
jedis.select(0);
|
|
||||||
jedis.srem("pairs",matchKey);
|
|
||||||
// jedis.del(matchKey);
|
// jedis.del(matchKey);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
Matcher m = Matchers.getInstance().getMatcher(oldTree, newTree);
|
|
||||||
m.match();
|
|
||||||
|
|
||||||
|
|
||||||
ActionGenerator ag = new ActionGenerator(oldTree, newTree, m.getMappings());
|
|
||||||
ag.generate();
|
|
||||||
List<Action> actions = ag.getActions();
|
|
||||||
|
|
||||||
// double chawatheSimilarity1 = m.chawatheSimilarity(oldTree, newTree);
|
|
||||||
// String chawatheSimilarity = String.format("%1.2f", chawatheSimilarity1);
|
|
||||||
// double diceSimilarity1 = m.diceSimilarity(oldTree, newTree);
|
|
||||||
// String diceSimilarity = String.format("%1.2f", diceSimilarity1);
|
|
||||||
// double jaccardSimilarity1 = m.jaccardSimilarity(oldTree, newTree);
|
|
||||||
// String jaccardSimilarity = String.format("%1.2f", jaccardSimilarity1);
|
|
||||||
|
|
||||||
String editDistance;
|
|
||||||
// if(keyName.split("-")[1].equals("1")){
|
|
||||||
// if(oldTree.getType() == newTree.getType()){
|
|
||||||
// editDistance = "0";
|
|
||||||
// }else{
|
|
||||||
// editDistance = "1";
|
|
||||||
// }
|
|
||||||
// }else {
|
|
||||||
// editDistance = String.valueOf(actions.size());
|
|
||||||
// }
|
|
||||||
editDistance = String.valueOf(actions.size());
|
|
||||||
// String result = i + "," + j + "," + chawatheSimilarity + "," + diceSimilarity + "," + jaccardSimilarity + "," + editDistance;
|
|
||||||
String result = i + "," + j + "," + editDistance;
|
|
||||||
|
|
||||||
String matchKey = keyName+"_" + (String.valueOf(i)) + "_" + String.valueOf(j);
|
|
||||||
|
|
||||||
// if (((Double) chawatheSimilarity1).equals(1.0) || ((Double) diceSimilarity1).equals(1.0)
|
|
||||||
// || ((Double) jaccardSimilarity1).equals(1.0) || editDistance.equals("0")) {
|
|
||||||
if (editDistance.equals("0")) {
|
|
||||||
// log.info("{} tagged to be similar" ,matchKey);
|
|
||||||
|
|
||||||
if (treeType.equals("action")) {
|
|
||||||
// log.info(editDistance);
|
|
||||||
|
|
||||||
HierarchicalActionSet oldProject = oldPair.getValue1();
|
|
||||||
HierarchicalActionSet newProject = newPair.getValue1();
|
|
||||||
|
|
||||||
// oldTree = EDiffHelper.getTargets(keyName, i, outerPool,innerPool);
|
|
||||||
oldTree = EDiffHelper.getTargets(oldProject);
|
|
||||||
// newTree = EDiffHelper.getTargets(keyName, j, outerPool,innerPool);
|
|
||||||
newTree = EDiffHelper.getTargets(newProject);
|
|
||||||
|
|
||||||
m = Matchers.getInstance().getMatcher(oldTree, newTree);
|
|
||||||
m.match();
|
|
||||||
|
|
||||||
|
|
||||||
ag = new ActionGenerator(oldTree, newTree, m.getMappings());
|
|
||||||
ag.generate();
|
|
||||||
actions = ag.getActions();
|
|
||||||
|
|
||||||
if(keyName.split("-")[1].equals("1")){
|
|
||||||
if(oldTree.getType() == newTree.getType()){
|
|
||||||
editDistance = "0";
|
|
||||||
}else{
|
|
||||||
editDistance = "1";
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
editDistance = String.valueOf(actions.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(editDistance.equals("0")){
|
|
||||||
jedis.select(2);
|
|
||||||
jedis.set(matchKey, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}else{
|
|
||||||
|
|
||||||
jedis.select(2);
|
|
||||||
jedis.set(matchKey, result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(oldTree.toStaticHashString().equals(newTree.toStaticHashString())){
|
||||||
|
String editDistance = "0";
|
||||||
|
String result = i + "," + j + "," + editDistance;
|
||||||
|
if (editDistance.equals("0")) {
|
||||||
|
|
||||||
|
if (treeType.equals("action")) {
|
||||||
|
HierarchicalActionSet oldProject = oldPair.getValue1();
|
||||||
|
HierarchicalActionSet newProject = newPair.getValue1();
|
||||||
|
|
||||||
|
oldTree = EDiffHelper.getTargets(oldProject);
|
||||||
|
newTree = EDiffHelper.getTargets(newProject);
|
||||||
|
if (oldTree.toStaticHashString().equals(newTree.toStaticHashString())) {
|
||||||
|
try (Jedis jedis = innerPool.getResource()) {
|
||||||
|
// jedis.del(matchKey);
|
||||||
|
jedis.select(2);
|
||||||
|
jedis.set(matchKey, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try (Jedis jedis = innerPool.getResource()) {
|
||||||
|
// jedis.del(matchKey);
|
||||||
|
jedis.select(2);
|
||||||
|
jedis.set(matchKey, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
// if(oldTree.toString().equals(newTree.toString())) {
|
||||||
|
// Matcher m = Matchers.getInstance().getMatcher(oldTree, newTree);
|
||||||
|
// m.match();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// ActionGenerator ag = new ActionGenerator(oldTree, newTree, m.getMappings());
|
||||||
|
// ag.generate();
|
||||||
|
// List<Action> actions = ag.getActions();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// String editDistance;
|
||||||
|
//
|
||||||
|
// editDistance = String.valueOf(actions.size());
|
||||||
|
// String result = i + "," + j + "," + editDistance;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// if (editDistance.equals("0")) {
|
||||||
|
//
|
||||||
|
// if (treeType.equals("action")) {
|
||||||
|
//
|
||||||
|
// HierarchicalActionSet oldProject = oldPair.getValue1();
|
||||||
|
// HierarchicalActionSet newProject = newPair.getValue1();
|
||||||
|
//
|
||||||
|
// oldTree = EDiffHelper.getTargets(oldProject);
|
||||||
|
// newTree = EDiffHelper.getTargets(newProject);
|
||||||
|
//
|
||||||
|
// if(oldTree.toString().equals(newTree.toString())) {
|
||||||
|
// m = Matchers.getInstance().getMatcher(oldTree, newTree);
|
||||||
|
// m.match();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// ag = new ActionGenerator(oldTree, newTree, m.getMappings());
|
||||||
|
// ag.generate();
|
||||||
|
// actions = ag.getActions();
|
||||||
|
//
|
||||||
|
// editDistance = String.valueOf(actions.size());
|
||||||
|
//
|
||||||
|
// if (editDistance.equals("0")) {
|
||||||
|
// try (Jedis jedis = innerPool.getResource()) {
|
||||||
|
// jedis.del(matchKey);
|
||||||
|
// jedis.select(2);
|
||||||
|
// jedis.set(matchKey, result);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// } else {
|
||||||
|
// try (Jedis jedis = innerPool.getResource()) {
|
||||||
|
// jedis.del(matchKey);
|
||||||
|
// jedis.select(2);
|
||||||
|
// jedis.set(matchKey, result);
|
||||||
|
// }
|
||||||
|
//// jedis.select(2);
|
||||||
|
//// jedis.set(matchKey, result);
|
||||||
|
//// samePairs.add(matchKey);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
errorPairs.add(matchKey);
|
||||||
|
// jedis.select(0);
|
||||||
|
//// jedis.srem("pairs",matchKey);
|
||||||
|
//
|
||||||
|
// jedis.hset(matchKey, "0", "1");
|
||||||
|
|
||||||
|
log.debug("{} not comparable", pairName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
jedis.select(0);
|
|
||||||
jedis.srem("pairs",matchKey);
|
|
||||||
// jedis.del(matchKey);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
|
|
||||||
log.debug("{} not comparable", pairName);
|
|
||||||
// e.printStackTrace();
|
|
||||||
// throw e;
|
|
||||||
|
|
||||||
|
|
||||||
}finally {
|
|
||||||
if (jedis != null) {
|
|
||||||
jedis.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Regular → Executable
+1
-1
@@ -20,6 +20,6 @@ public class RunnableCompare implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
comparer.coreCompare(name,type, innerPool, outerPool);
|
// comparer.coreCompare(name,type, innerPool, outerPool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+1
-1
@@ -105,7 +105,7 @@ public class EDiffHunkParser extends EDiffParser {
|
|||||||
|
|
||||||
try (Jedis inner = innerPool.getResource()) {
|
try (Jedis inner = innerPool.getResource()) {
|
||||||
|
|
||||||
inner.set(key, EDiffHelper.toString(actionSet));
|
inner.set(key.getBytes(), EDiffHelper.toByteArray(actionSet));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+3
-1
@@ -4,6 +4,8 @@ import edu.lu.uni.serval.fixminer.akka.ediff.HierarchicalActionSet;
|
|||||||
import edu.lu.uni.serval.utils.CallShell;
|
import edu.lu.uni.serval.utils.CallShell;
|
||||||
import edu.lu.uni.serval.utils.EDiffHelper;
|
import edu.lu.uni.serval.utils.EDiffHelper;
|
||||||
import edu.lu.uni.serval.utils.PoolBuilder;
|
import edu.lu.uni.serval.utils.PoolBuilder;
|
||||||
|
import org.redisson.Redisson;
|
||||||
|
import org.redisson.api.RedissonClient;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import redis.clients.jedis.Jedis;
|
import redis.clients.jedis.Jedis;
|
||||||
@@ -137,7 +139,7 @@ public class StoreEDiffInCache {
|
|||||||
|
|
||||||
try (Jedis inner = innerPool.getResource()) {
|
try (Jedis inner = innerPool.getResource()) {
|
||||||
|
|
||||||
inner.set(key, EDiffHelper.toString(actionSet));
|
inner.set(key.getBytes(), EDiffHelper.toByteArray(actionSet));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+50
-49
@@ -22,37 +22,37 @@ public class ClusterToPattern {
|
|||||||
Jedis jedis = new Jedis("127.0.0.1",Integer.valueOf(port),20000000);
|
Jedis jedis = new Jedis("127.0.0.1",Integer.valueOf(port),20000000);
|
||||||
// writeTofFile(shapesFolder, outerPool);
|
// writeTofFile(shapesFolder, outerPool);
|
||||||
|
|
||||||
File file = new File(shapesFolder);
|
// File file = new File(shapesFolder);
|
||||||
|
//
|
||||||
|
//
|
||||||
File[] files = file.listFiles();
|
// File[] files = file.listFiles();
|
||||||
ArrayList<String> strings = new ArrayList<>();
|
// ArrayList<String> strings = new ArrayList<>();
|
||||||
List<File> folders = Arrays.stream(files).filter(x -> x.isDirectory())
|
// List<File> folders = Arrays.stream(files).filter(x -> x.isDirectory())
|
||||||
.collect(Collectors.toList());
|
// .collect(Collectors.toList());
|
||||||
for (File target : folders) {
|
// for (File target : folders) {
|
||||||
File[] files2 = target.listFiles();
|
// File[] files2 = target.listFiles();
|
||||||
for (File file1 : files2) {
|
// for (File file1 : files2) {
|
||||||
File[] files1 = file1.listFiles();
|
// File[] files1 = file1.listFiles();
|
||||||
strings.add(((File)files1[0]).listFiles()[0].getName());
|
// strings.add(((File)files1[0]).listFiles()[0].getName());
|
||||||
// System.out.println();
|
//// System.out.println();
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// Collection<File> files1 = FileUtils.listFiles(target, null, true);
|
//// Collection<File> files1 = FileUtils.listFiles(target, null, true);
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
for (String string : strings) {
|
// for (String string : strings) {
|
||||||
export("*"+string,jedis);
|
// export("*"+string,jedis);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// String export = export("VariableDeclarationStatement"+"/*/camel_8f0c15_ab3e17_camel-core#src#main#java#org#apache#camel#component#bean#BeanInfo.txt_0", jedis);
|
// String export = export("VariableDeclarationStatement"+"/*/camel_8f0c15_ab3e17_camel-core#src#main#java#org#apache#camel#component#bean#BeanInfo.txt_0", jedis);
|
||||||
// String export = export(args[0], jedis);
|
String export = export(args[0], jedis);
|
||||||
// System.out.println(export);
|
System.out.println(export);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void export(String filename,Jedis outer) throws IOException, ClassNotFoundException {
|
private static String export(String filename,Jedis outer) throws IOException, ClassNotFoundException {
|
||||||
|
|
||||||
// String key = shape.getName() + "/*/" + file.getName();
|
// String key = shape.getName() + "/*/" + file.getName();
|
||||||
// Jedis outer = outerPool.getResource();
|
// Jedis outer = outerPool.getResource();
|
||||||
@@ -64,30 +64,31 @@ public class ClusterToPattern {
|
|||||||
throw new Error("cok key");
|
throw new Error("cok key");
|
||||||
}
|
}
|
||||||
|
|
||||||
String si = outer.get(s);
|
byte[] si = outer.get(s.getBytes());
|
||||||
HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.fromString(si);
|
// HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.fromString(si);
|
||||||
ITree tree = null;
|
HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.fromByteArray(si);
|
||||||
ITree parent = null;
|
// ITree tree = null;
|
||||||
ITree children =null;
|
// ITree parent = null;
|
||||||
TreeContext tc = new TreeContext();
|
// ITree children =null;
|
||||||
tree = EDiffHelper.getASTTree(actionSet, parent, children,tc);
|
// TreeContext tc = new TreeContext();
|
||||||
tree.setParent(null);
|
// tree = EDiffHelper.getASTTree(actionSet, parent, children,tc);
|
||||||
tc.validate();
|
// tree.setParent(null);
|
||||||
|
// tc.validate();
|
||||||
|
//
|
||||||
|
// String s2 = tree.toStaticHashString();
|
||||||
|
// try(FileWriter fw = new FileWriter("myfile.txt", true);
|
||||||
|
// BufferedWriter bw = new BufferedWriter(fw);
|
||||||
|
// PrintWriter out = new PrintWriter(bw))
|
||||||
|
// {
|
||||||
|
// out.println(s2);
|
||||||
|
// //more code
|
||||||
|
// } catch (IOException e) {
|
||||||
|
// //exception handling left as an exercise for the reader
|
||||||
|
// }
|
||||||
|
|
||||||
String s2 = tree.toStaticHashString();
|
String s1 = actionSet.toString();
|
||||||
try(FileWriter fw = new FileWriter("myfile.txt", true);
|
outer.close();
|
||||||
BufferedWriter bw = new BufferedWriter(fw);
|
return s1;
|
||||||
PrintWriter out = new PrintWriter(bw))
|
|
||||||
{
|
|
||||||
out.println(s2);
|
|
||||||
//more code
|
|
||||||
} catch (IOException e) {
|
|
||||||
//exception handling left as an exercise for the reader
|
|
||||||
}
|
|
||||||
|
|
||||||
// String s1 = actionSet.toString();
|
|
||||||
// outer.close();
|
|
||||||
// return s1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Regular → Executable
+101
-67
@@ -43,6 +43,24 @@ public class EDiffHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Object fromByteArray( byte[] data ) throws IOException,
|
||||||
|
ClassNotFoundException {
|
||||||
|
// byte [] data = Base64.getDecoder().decode( s );
|
||||||
|
ObjectInputStream ois = new ObjectInputStream(
|
||||||
|
new ByteArrayInputStream( data ) );
|
||||||
|
Object o = ois.readObject();
|
||||||
|
ois.close();
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
/** Write the object to a Base64 string. */
|
||||||
|
public static byte[] toByteArray(Serializable o ) throws IOException {
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
ObjectOutputStream oos = new ObjectOutputStream( baos );
|
||||||
|
oos.writeObject( o );
|
||||||
|
oos.close();
|
||||||
|
return baos.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
public static ITree getTokenTree(HierarchicalActionSet actionSet, ITree parent, ITree children,TreeContext tc){
|
public static ITree getTokenTree(HierarchicalActionSet actionSet, ITree parent, ITree children,TreeContext tc){
|
||||||
|
|
||||||
int newType = 0;
|
int newType = 0;
|
||||||
@@ -230,39 +248,44 @@ public class EDiffHelper {
|
|||||||
public static ITree getShapes(String prefix, String fn, JedisPool outerPool,JedisPool innerPool) {
|
public static ITree getShapes(String prefix, String fn, JedisPool outerPool,JedisPool innerPool) {
|
||||||
|
|
||||||
ITree tree = null;
|
ITree tree = null;
|
||||||
Jedis inner = null;
|
// Jedis inner = null;
|
||||||
Jedis outer = null;
|
// Jedis outer = null;
|
||||||
try {
|
try (Jedis inner = innerPool.getResource(); Jedis outer = outerPool.getResource()) {
|
||||||
inner = innerPool.getResource();
|
// inner = innerPool.getResource();
|
||||||
while (!inner.ping().equals("PONG")){
|
try {
|
||||||
log.info("wait");
|
while (!inner.ping().equals("PONG")) {
|
||||||
}
|
log.info("wait");
|
||||||
inner.select(1);
|
}
|
||||||
String dist2load = inner.get(prefix+"-"+fn);
|
inner.select(1);
|
||||||
outer = outerPool.getResource();
|
String dist2load = inner.get(prefix + "-" + fn);
|
||||||
outer.select(0);
|
|
||||||
String s = outer.get(prefix.replace("-","/") +"/"+dist2load);
|
|
||||||
HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.fromString(s);
|
|
||||||
|
|
||||||
ITree parent = null;
|
// outer = outerPool.getResource();
|
||||||
ITree children =null;
|
outer.select(0);
|
||||||
TreeContext tc = new TreeContext();
|
String key = prefix.replace("-", "/") + "/" + dist2load;
|
||||||
tree = EDiffHelper.getASTTree(actionSet, parent, children,tc);
|
byte[] s = outer.get(key.getBytes());
|
||||||
//tree.setParent(null);
|
HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.fromByteArray(s);
|
||||||
tc.validate();
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
ITree parent = null;
|
||||||
e.printStackTrace();
|
ITree children = null;
|
||||||
} catch (ClassNotFoundException e) {
|
TreeContext tc = new TreeContext();
|
||||||
e.printStackTrace();
|
tree = EDiffHelper.getASTTree(actionSet, parent, children, tc);
|
||||||
}finally {
|
//tree.setParent(null);
|
||||||
if (inner != null) {
|
tc.validate();
|
||||||
inner.close();
|
|
||||||
}
|
} catch (IOException e) {
|
||||||
if (outer != null) {
|
e.printStackTrace();
|
||||||
outer.close();
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// finally {
|
||||||
|
// if (inner != null) {
|
||||||
|
// inner.close();
|
||||||
|
// }
|
||||||
|
// if (outer != null) {
|
||||||
|
// outer.close();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
return tree;
|
return tree;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -381,28 +404,31 @@ public class EDiffHelper {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
String dist2load = null;
|
String dist2load = null;
|
||||||
String si = null;
|
byte[] si = null;
|
||||||
try (Jedis inner = innerPool.getResource()){
|
try (Jedis inner = innerPool.getResource();Jedis outer = outerPool.getResource()){
|
||||||
|
|
||||||
|
inner.select(1);
|
||||||
|
dist2load = inner.get(prefix + "-" + firstValue);
|
||||||
|
|
||||||
inner.select(1);
|
|
||||||
dist2load = inner.get(prefix + "-" + firstValue);
|
|
||||||
}
|
|
||||||
try(Jedis outer = outerPool.getResource()) {
|
|
||||||
outer.select(0);
|
outer.select(0);
|
||||||
|
String[] split = prefix.split("-");
|
||||||
String s = null;//inner.get(prefix.replace("-","/") +"/"+dist2load);
|
String s = null;//inner.get(prefix.replace("-","/") +"/"+dist2load);
|
||||||
Set<String> keys = outer.keys(prefix.split("-")[0] + "/*/" + dist2load);
|
// Set<String> keys = outer.keys(split[0] + "/"+split[1]+"/" + dist2load);
|
||||||
if (keys.size() == 1) {
|
String key = split[0] + "/"+split[1]+"/" + dist2load;
|
||||||
s = (String) keys.toArray()[0];
|
// if (keys.size() == 1) {
|
||||||
} else {
|
// s = (String) keys.toArray()[0];
|
||||||
throw new Error("cok key");
|
// } else {
|
||||||
}
|
// throw new Error("cok key");
|
||||||
si = outer.get(s);
|
// }
|
||||||
}
|
si = outer.get(key.getBytes());
|
||||||
|
|
||||||
|
// String key = prefix.replace("-", "/") + "/" + dist2load;
|
||||||
|
// byte[] s = outer.get(key.getBytes());
|
||||||
|
actionSet = (HierarchicalActionSet) EDiffHelper.fromByteArray(si);
|
||||||
|
|
||||||
// String filename = project + "/"+type+"/" + pureFileName + ".txt_" + actionSetPosition;
|
// String filename = project + "/"+type+"/" + pureFileName + ".txt_" + actionSetPosition;
|
||||||
actionSet = (HierarchicalActionSet) EDiffHelper.fromString(si);
|
// actionSet = (HierarchicalActionSet) EDiffHelper.fromString(si);
|
||||||
|
}
|
||||||
|
|
||||||
ITree parent = null;
|
ITree parent = null;
|
||||||
ITree children = null;
|
ITree children = null;
|
||||||
@@ -439,28 +465,33 @@ public class EDiffHelper {
|
|||||||
|
|
||||||
|
|
||||||
ITree tree = null;
|
ITree tree = null;
|
||||||
Jedis inner = null;
|
// Jedis inner = null;
|
||||||
Jedis outer = null;
|
// Jedis outer = null;
|
||||||
|
|
||||||
|
try{
|
||||||
try {
|
try (Jedis inner = innerPool.getResource();Jedis outer = outerPool.getResource()) {
|
||||||
inner = innerPool.getResource();
|
// inner = innerPool.getResource();
|
||||||
inner.select(1);
|
inner.select(1);
|
||||||
String dist2load = inner.get(prefix + "-" + firstValue);
|
String dist2load = inner.get(prefix + "-" + firstValue);
|
||||||
outer = outerPool.getResource();
|
// outer = outerPool.getResource();
|
||||||
outer.select(0);
|
outer.select(0);
|
||||||
String s = null;//inner.get(prefix.replace("-","/") +"/"+dist2load);
|
// String s = null;//inner.get(prefix.replace("-","/") +"/"+dist2load);
|
||||||
Set<String> keys = outer.keys(prefix.split("-")[0] + "/*/" + dist2load);
|
// Set<String> keys = outer.keys(prefix.split("-")[0] + "/*/" + dist2load);
|
||||||
if (keys.size() == 1) {
|
// if (keys.size() == 1) {
|
||||||
s = (String) keys.toArray()[0];
|
// s = (String) keys.toArray()[0];
|
||||||
} else {
|
// } else {
|
||||||
throw new Error("cok key");
|
// throw new Error("cok key");
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
// String filename = project + "/"+type+"/" + pureFileName + ".txt_" + actionSetPosition;
|
// String filename = project + "/"+type+"/" + pureFileName + ".txt_" + actionSetPosition;
|
||||||
String si = outer.get(s);
|
String[] split = prefix.split("-");
|
||||||
HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.fromString(si);
|
// String s = null;//inner.get(prefix.replace("-","/") +"/"+dist2load);
|
||||||
|
// Set<String> keys = outer.keys(split[0] + "/"+split[1]+"/" + dist2load);
|
||||||
|
String key = split[0] + "/"+split[1]+"/" + dist2load;
|
||||||
|
byte[] si = outer.get(key.getBytes());
|
||||||
|
// HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.fromString(si);
|
||||||
|
HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.fromByteArray(si);
|
||||||
|
|
||||||
|
|
||||||
ITree parent = null;
|
ITree parent = null;
|
||||||
@@ -470,21 +501,24 @@ public class EDiffHelper {
|
|||||||
tree.setParent(null);
|
tree.setParent(null);
|
||||||
tc.validate();
|
tc.validate();
|
||||||
// getLeaves(tree);
|
// getLeaves(tree);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
|
||||||
if (inner != null) {
|
|
||||||
inner.close();
|
|
||||||
}
|
|
||||||
if (outer != null) {
|
|
||||||
outer.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// finally {
|
||||||
|
// if (inner != null) {
|
||||||
|
// inner.close();
|
||||||
|
// }
|
||||||
|
// if (outer != null) {
|
||||||
|
// outer.close();
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Regular → Executable
+3
@@ -15,6 +15,9 @@ public class PoolBuilder {
|
|||||||
static final JedisPoolConfig poolConfig = buildPoolConfig();
|
static final JedisPoolConfig poolConfig = buildPoolConfig();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static JedisPoolConfig buildPoolConfig() {
|
private static JedisPoolConfig buildPoolConfig() {
|
||||||
final JedisPoolConfig poolConfig = new JedisPoolConfig();
|
final JedisPoolConfig poolConfig = new JedisPoolConfig();
|
||||||
poolConfig.setMaxTotal(1024);
|
poolConfig.setMaxTotal(1024);
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
Regular → Executable
Reference in New Issue
Block a user