This commit is contained in:
ANIL KOYUNCU
2020-02-17 17:48:45 +01:00
parent faac1391b7
commit a8c8b19585
14 changed files with 534 additions and 1117 deletions
+9
View File
@@ -7,7 +7,16 @@
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" /> <outputRelativeToContentRoot value="true" />
<module name="FixPatternMiner" /> <module name="FixPatternMiner" />
<module name="gen.jdt" />
<module name="gen.srcml" />
<module name="client.diff" />
<module name="fixminer_source" />
<module name="client" />
<module name="core" />
</profile> </profile>
</annotationProcessing> </annotationProcessing>
<bytecodeTargetLevel>
<module name="simple-utils" target="1.8" />
</bytecodeTargetLevel>
</component> </component>
</project> </project>
+8 -1
View File
@@ -1,6 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM"> <component name="Encoding">
<file url="file://$PROJECT_DIR$" charset="UTF-8" /> <file url="file://$PROJECT_DIR$" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../gumtree/client.diff/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../gumtree/client.diff/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../gumtree/client/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../gumtree/core/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../gumtree/gen.jdt/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../gumtree/gen.srcml/src/main/java" charset="UTF-8" />
</component> </component>
</project> </project>
+2 -1
View File
@@ -5,10 +5,11 @@
<option name="originalFiles"> <option name="originalFiles">
<list> <list>
<option value="$PROJECT_DIR$/pom.xml" /> <option value="$PROJECT_DIR$/pom.xml" />
<option value="$PROJECT_DIR$/../gumtree/pom.xml" />
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>
Generated
+1
View File
@@ -2,5 +2,6 @@
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/../gumtree" vcs="Git" />
</component> </component>
</project> </project>
+208 -652
View File
File diff suppressed because it is too large Load Diff
+5 -66
View File
@@ -12,7 +12,7 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<akka.version>2.4.11</akka.version> <akka.version>2.4.17</akka.version>
<logback.version>1.1.2</logback.version> <logback.version>1.1.2</logback.version>
<slf4j-api.version>1.7.7</slf4j-api.version> <slf4j-api.version>1.7.7</slf4j-api.version>
</properties> </properties>
@@ -25,12 +25,6 @@
<version>1.2</version> <version>1.2</version>
</dependency> </dependency>
<!--<dependency>-->
<!--<groupId>edu.lu.uni</groupId>-->
<!--<artifactId>simple-utils</artifactId>-->
<!--<version>0.0.1-SNAPSHOT</version>-->
<!--</dependency>-->
<!-- akka --> <!-- akka -->
<dependency> <dependency>
<groupId>com.typesafe.akka</groupId> <groupId>com.typesafe.akka</groupId>
@@ -41,18 +35,21 @@
<dependency> <dependency>
<groupId>com.github.gumtreediff</groupId> <groupId>com.github.gumtreediff</groupId>
<artifactId>core</artifactId> <artifactId>core</artifactId>
<scope>compile</scope>
<version>2.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.gumtreediff</groupId> <groupId>com.github.gumtreediff</groupId>
<artifactId>gen.jdt</artifactId> <artifactId>gen.jdt</artifactId>
<scope>compile</scope>
<version>2.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.gumtreediff</groupId> <groupId>com.github.gumtreediff</groupId>
<artifactId>gen.srcml</artifactId> <artifactId>gen.srcml</artifactId>
<scope>compile</scope>
<version>2.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
</dependency> </dependency>
@@ -75,18 +72,11 @@
<version>${logback.version}</version> <version>${logback.version}</version>
</dependency> </dependency>
<!--<dependency>-->
<!--<groupId>edu.lu.uni.serval</groupId>-->
<!--<artifactId>GitTraveller</artifactId>-->
<!--<version>0.0.1-SNAPSHOT</version>-->
<!--</dependency>-->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.12</version> <version>4.12</version>
<scope>test</scope> <!-- <scope>test</scope>-->
</dependency> </dependency>
<dependency> <dependency>
@@ -102,65 +92,14 @@
<version>1.3</version> <version>1.3</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>com.rabbitmq</groupId>-->
<!-- <artifactId>amqp-client</artifactId>-->
<!-- <version>4.0.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-core -->
<!-- <dependency>-->
<!-- <groupId>org.apache.lucene</groupId>-->
<!-- <artifactId>lucene-core</artifactId>-->
<!-- <version>4.8.0</version>-->
<!-- </dependency>-->
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-analyzers-common -->
<!-- <dependency>-->
<!-- <groupId>org.apache.lucene</groupId>-->
<!-- <artifactId>lucene-analyzers-common</artifactId>-->
<!-- <version>4.8.0</version>-->
<!-- </dependency>-->
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-math3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream -->
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.3.1</version>
</dependency>
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<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>
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>4.0.2</version>
</dependency>
@@ -22,7 +22,7 @@ public class Launcher {
Properties appProps = new Properties(); Properties appProps = new Properties();
String appConfigPath = "/Users/anilkoyuncu/projects/fixminer/fixminer_source/src/main/resource/app.properties"; String appConfigPath = "src/main/resource/app.properties";
// String appConfigPath = args[0]; // String appConfigPath = args[0];
appProps.load(new FileInputStream(appConfigPath)); appProps.load(new FileInputStream(appConfigPath));
@@ -40,12 +40,12 @@ public class Launcher {
String redisPath = appProps.getProperty("redisPath","FORKJOIN"); String redisPath = appProps.getProperty("redisPath","FORKJOIN");
String srcMLPath = appProps.getProperty("srcMLPath","FORKJOIN"); String srcMLPath = appProps.getProperty("srcMLPath","FORKJOIN");
String parameter = args[2]; // String parameter = args[2];
// String parameter = "L1"; String parameter = "L1";
// String parameter = "if"; // String parameter = "if";
// String parameter = "add"; // String parameter = "add";
String jobType = args[1]; // String jobType = args[1];
// String jobType = "RICHEDITSCRIPT"; String jobType = "RICHEDITSCRIPT";
// String jobType = "LOAD"; // String jobType = "LOAD";
// String jobType = "COMPARE"; // String jobType = "COMPARE";
@@ -196,226 +196,226 @@ public class CompareTrees {
return true; return true;
} }
public static void coreCompare(String pairName, String treeType,JedisPool innerPool,ArrayList<String> samePairs,ArrayList<String> errorPairs, HashMap<String, String> filenames,JedisPool outerPool ) { // public static void coreCompare(String pairName, String treeType,JedisPool innerPool,ArrayList<String> samePairs,ArrayList<String> errorPairs, HashMap<String, String> filenames,JedisPool outerPool ) {
// if (samePairs.size() % 1000 == 0) {
// log.info("Same pairs size "+samePairs.size());
// }
ITree oldTree = null;
ITree newTree = null;
Pair<ITree, HierarchicalActionSet> oldPair = null;
Pair<ITree, HierarchicalActionSet> newPair = null;
String matchKey = null;
innerPool = outerPool;
try {
String[] split = pairName.split("/");
String i = split[1];
String j = split[2];
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);
// JedisPool outerPool = null;
switch (treeType) {
case "single":
// String oldShapeTree = EDiffHelper.getTreeString(keyName, i, outerPool, filenames,"shapeTree");
// String newShapeTree = EDiffHelper.getTreeString(keyName, j, outerPool, filenames,"shapeTree");
// //
// String oldActionTree = EDiffHelper.getTreeString(keyName, i, outerPool, filenames,"actionTree"); //// if (samePairs.size() % 1000 == 0) {
// String newActionTree = EDiffHelper.getTreeString(keyName, j, outerPool, filenames,"actionTree"); //// log.info("Same pairs size "+samePairs.size());
//// }
// //
// String oldTargetTree = EDiffHelper.getTreeString(keyName, i, outerPool, filenames,"targetTree"); // ITree oldTree = null;
// String newTargetTree = EDiffHelper.getTreeString(keyName, j, outerPool, filenames,"targetTree"); // ITree newTree = null;
// Pair<ITree, HierarchicalActionSet> oldPair = null;
// Pair<ITree, HierarchicalActionSet> newPair = null;
// String matchKey = null;
//
// innerPool = outerPool;
//
// try {
//
// String[] split = pairName.split("/");
// //
// //
// if(oldShapeTree.equals(newShapeTree)){ // String i = split[1];
// if(oldActionTree.equals(newActionTree)){ // String j = split[2];
// if(oldTargetTree.equals(newTargetTree)){ // String keyName = split[0];
// samePairs.add(matchKey); // matchKey = keyName + "/" + (String.valueOf(i)) + "/" + String.valueOf(j);
// } //// jedis.select(0);
// } //// Set<String> keys = jedis.keys(matchKey);
// } //// if (keys.size() > 0) {
return; //// jedis.del(matchKey);
// break; //// } else {
//// return;
//// }
case "shape":
oldTree = EDiffHelper.getShapes(keyName, i, outerPool,filenames);
newTree = EDiffHelper.getShapes(keyName, j, outerPool,filenames);
break;
case "action":
oldPair = EDiffHelper.getActions(keyName, i, outerPool, filenames);
newPair = EDiffHelper.getActions(keyName, j, outerPool, filenames);
oldTree = oldPair.getValue0();
newTree = newPair.getValue0();
break;
case "token":
oldTree = EDiffHelper.getTokens(keyName, i, outerPool, filenames);
newTree = EDiffHelper.getTokens(keyName, j, outerPool, filenames);
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);
}
int retval = Double.compare(overallSimi, Double.valueOf(1));
if (retval >= 0) {
String result = i + "," + j + "," + String.join(",", oldTokens);
// jedis.select(2);
// jedis.set(matchKey, result);
// try (Jedis jedis = innerPool.getResource()) {
//// jedis.del(matchKey);
// jedis.select(2);
// jedis.set(matchKey, result);
// }
samePairs.add(matchKey);
// try (Jedis jedis = innerPool.getResource()) {
//// jedis.del(matchKey);
// jedis.select(2);
// jedis.set(matchKey, result);
// }
}
// jedis.select(0);
//// jedis.srem("pairs",matchKey); //// jedis.srem("pairs",matchKey);
// jedis.del(matchKey); //// JedisPool outerPool = null;
// switch (treeType) {
return; // case "single":
default:
break;
}
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())) {
samePairs.add(matchKey);
// try (Jedis jedis = innerPool.getResource()) {
//// jedis.del(matchKey);
// jedis.select(2);
// jedis.set(matchKey, result);
// //
// } //// String oldShapeTree = EDiffHelper.getTreeString(keyName, i, outerPool, filenames,"shapeTree");
} //// String newShapeTree = EDiffHelper.getTreeString(keyName, j, outerPool, filenames,"shapeTree");
} else { ////
samePairs.add(matchKey); //// String oldActionTree = EDiffHelper.getTreeString(keyName, i, outerPool, filenames,"actionTree");
// try (Jedis jedis = innerPool.getResource()) { //// String newActionTree = EDiffHelper.getTreeString(keyName, j, outerPool, filenames,"actionTree");
//// jedis.del(matchKey); ////
// jedis.select(2); //// String oldTargetTree = EDiffHelper.getTreeString(keyName, i, outerPool, filenames,"targetTree");
// jedis.set(matchKey, result); //// String newTargetTree = EDiffHelper.getTreeString(keyName, j, outerPool, filenames,"targetTree");
// ////
// } ////
} //// if(oldShapeTree.equals(newShapeTree)){
} //// if(oldActionTree.equals(newActionTree)){
//// if(oldTargetTree.equals(newTargetTree)){
//// samePairs.add(matchKey);
} //// }
// if(oldTree.toString().equals(newTree.toString())) { //// }
// Matcher m = Matchers.getInstance().getMatcher(oldTree, newTree); //// }
// m.match(); // return;
//// break;
// //
// //
// ActionGenerator ag = new ActionGenerator(oldTree, newTree, m.getMappings()); // case "shape":
// ag.generate(); // oldTree = EDiffHelper.getShapes(keyName, i, outerPool,filenames);
// List<Action> actions = ag.getActions(); // newTree = EDiffHelper.getShapes(keyName, j, outerPool,filenames);
// break;
// case "action":
//
// oldPair = EDiffHelper.getActions(keyName, i, outerPool, filenames);
// newPair = EDiffHelper.getActions(keyName, j, outerPool, filenames);
// oldTree = oldPair.getValue0();
// newTree = newPair.getValue0();
// //
// //
// String editDistance; // break;
// case "token":
// oldTree = EDiffHelper.getTokens(keyName, i, outerPool, filenames);
// newTree = EDiffHelper.getTokens(keyName, j, outerPool, filenames);
// //
// editDistance = String.valueOf(actions.size()); // 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);
//
// }
//
//
// int retval = Double.compare(overallSimi, Double.valueOf(1));
//
// if (retval >= 0) {
// String result = i + "," + j + "," + String.join(",", oldTokens);
//// jedis.select(2);
//// jedis.set(matchKey, result);
//// try (Jedis jedis = innerPool.getResource()) {
////// jedis.del(matchKey);
//// jedis.select(2);
//// jedis.set(matchKey, result);
//// }
// samePairs.add(matchKey);
//// try (Jedis jedis = innerPool.getResource()) {
////// jedis.del(matchKey);
//// jedis.select(2);
//// jedis.set(matchKey, result);
//// }
// }
//// jedis.select(0);
////// jedis.srem("pairs",matchKey);
//// jedis.del(matchKey);
//
// return;
// default:
// break;
// }
//
//
//
// if(oldTree.toStaticHashString().equals(newTree.toStaticHashString())){
// String editDistance = "0";
// String result = i + "," + j + "," + editDistance; // String result = i + "," + j + "," + editDistance;
//
//
// if (editDistance.equals("0")) { // if (editDistance.equals("0")) {
// //
// if (treeType.equals("action")) { // if (treeType.equals("action")) {
//
// HierarchicalActionSet oldProject = oldPair.getValue1(); // HierarchicalActionSet oldProject = oldPair.getValue1();
// HierarchicalActionSet newProject = newPair.getValue1(); // HierarchicalActionSet newProject = newPair.getValue1();
// //
// oldTree = EDiffHelper.getTargets(oldProject); // oldTree = EDiffHelper.getTargets(oldProject);
// newTree = EDiffHelper.getTargets(newProject); // newTree = EDiffHelper.getTargets(newProject);
// // if (oldTree.toStaticHashString().equals(newTree.toStaticHashString())) {
// if(oldTree.toString().equals(newTree.toString())) { // samePairs.add(matchKey);
// m = Matchers.getInstance().getMatcher(oldTree, newTree); //// try (Jedis jedis = innerPool.getResource()) {
// m.match(); ////// jedis.del(matchKey);
// //// jedis.select(2);
// //// jedis.set(matchKey, result);
// 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 { // } else {
// try (Jedis jedis = innerPool.getResource()) { // samePairs.add(matchKey);
// jedis.del(matchKey); //// try (Jedis jedis = innerPool.getResource()) {
// jedis.select(2); ////// jedis.del(matchKey);
// jedis.set(matchKey, result); //// 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); //// 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);
// }
// }
} }
@@ -1,83 +0,0 @@
package edu.lu.uni.serval.fixminer.akka.ediff;
import java.io.ByteArrayOutputStream;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.*;
import com.esotericsoftware.kryo.pool.KryoFactory;
import com.esotericsoftware.kryo.pool.KryoPool;
import org.objenesis.strategy.SerializingInstantiatorStrategy;
public class DefaultKryoContext implements KryoContext{
private static final int DEFAULT_BUFFER = 1024 * 100;
private KryoPool pool;
public static KryoContext newKryoContextFactory()
{
return new DefaultKryoContext();
}
private DefaultKryoContext()
{
KryoFactory factory = new KryoFactoryImpl();
pool = new KryoPool.Builder(factory).softReferences().build();
}
private static class KryoFactoryImpl implements KryoFactory
{
@Override
public Kryo create() {
Kryo kryo = new Kryo();
kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new SerializingInstantiatorStrategy()));
return kryo;
}
}
@Override
public byte[] serialze(Object obj)
{
return serialze(obj, DEFAULT_BUFFER);
}
@Override
public byte[] serialze(Object obj, int bufferSize)
{
ByteArrayOutputStream base = new ByteArrayOutputStream();
UnsafeMemoryOutput output = new UnsafeMemoryOutput(base, bufferSize);
Kryo kryo = pool.borrow();
kryo.writeObject(output, obj);
output.flush();
byte[] serialized = base.toByteArray();
output.close();
// byte[] serialized = output.toBytes();
pool.release(kryo);
return serialized;
}
@Override
public Object deserialze(Class clazz, byte[] serialized)
{
Object obj;
Kryo kryo = pool.borrow();
UnsafeMemoryInput input = new UnsafeMemoryInput(serialized);
obj = kryo.readObject(input, clazz);
pool.release(kryo);
return obj;
}
}
@@ -211,9 +211,9 @@ public class HunkParserTest {
// tc.validate(); // tc.validate();
// parent.getLength(); // parent.getLength();
HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(dump); // HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(dump);
// HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.commonsDeserialize(dump); // HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.commonsDeserialize(dump);
actionSet.toString(); // actionSet.toString();
// CODE HERE // CODE HERE
@@ -248,8 +248,8 @@ public class HunkParserTest {
String j = "21"; String j = "21";
HashMap<String, String> filenames = AkkaTreeParser.filenames(outerPool); HashMap<String, String> filenames = AkkaTreeParser.filenames(outerPool);
oldPair = EDiffHelper.getActions(keyName, i, outerPool, filenames); // oldPair = EDiffHelper.getActions(keyName, i, outerPool, filenames);
newPair = EDiffHelper.getActions(keyName, j, outerPool, filenames); // newPair = EDiffHelper.getActions(keyName, j, outerPool, filenames);
ITree oldActionTree = oldPair.getValue0(); ITree oldActionTree = oldPair.getValue0();
ITree newActionTree = newPair.getValue0(); ITree newActionTree = newPair.getValue0();
HierarchicalActionSet oldProject = oldPair.getValue1(); HierarchicalActionSet oldProject = oldPair.getValue1();
@@ -19,8 +19,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static reactor.core.reactivestreams.PublisherFactory.forEach;
public class TestIntroClass { public class TestIntroClass {
@@ -62,7 +62,7 @@ public class EnhancedASTDiff {
.filter(x -> !x.getName().startsWith(".")) .filter(x -> !x.getName().startsWith("."))
.filter(x -> !x.getName().startsWith("cocci")) .filter(x -> !x.getName().startsWith("cocci"))
.filter(x -> !x.getName().endsWith(".index")) .filter(x -> !x.getName().endsWith(".index"))
.filter(x -> x.getName().endsWith("codeflaws")) // .filter(x -> x.getName().endsWith("codeflaws"))
.collect(Collectors.toList()); .collect(Collectors.toList());
@@ -5,7 +5,6 @@ import com.github.gumtreediff.gen.srcml.NodeMap_new;
import com.github.gumtreediff.tree.ITree; import com.github.gumtreediff.tree.ITree;
import com.github.gumtreediff.tree.TreeContext; import com.github.gumtreediff.tree.TreeContext;
import com.github.gumtreediff.tree.TreeUtils; import com.github.gumtreediff.tree.TreeUtils;
import edu.lu.uni.serval.fixminer.akka.ediff.DefaultKryoContext;
import edu.lu.uni.serval.fixminer.akka.ediff.HierarchicalActionSet; import edu.lu.uni.serval.fixminer.akka.ediff.HierarchicalActionSet;
import edu.lu.uni.serval.fixminer.akka.ediff.KryoContext; import edu.lu.uni.serval.fixminer.akka.ediff.KryoContext;
import org.apache.commons.lang3.SerializationUtils; import org.apache.commons.lang3.SerializationUtils;
@@ -74,16 +73,6 @@ public class EDiffHelper {
} }
public static byte[] kryoSerialize(Serializable o ){
KryoContext kryoContext = DefaultKryoContext.newKryoContextFactory();
return kryoContext.serialze(o);
}
public static Object kryoDeseerialize(byte[] data ){
KryoContext kryoContext = DefaultKryoContext.newKryoContextFactory();
return kryoContext.deserialze(HierarchicalActionSet.class,data);
}
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;
@@ -272,31 +261,31 @@ public class EDiffHelper {
} }
public static ITree getShapes(String prefix, String fn, JedisPool outerPool, HashMap<String, String> filenames) { // public static ITree getShapes(String prefix, String fn, JedisPool outerPool, HashMap<String, String> filenames) {
//
ITree tree = null; // ITree tree = null;
//
try (Jedis outer = outerPool.getResource()) { // try (Jedis outer = outerPool.getResource()) {
try { // try {
while (!outer.ping().equals("PONG")) { // while (!outer.ping().equals("PONG")) {
log.info("wait"); // log.info("wait");
} // }
String dist2load = filenames.get(prefix + "-" + fn); // String dist2load = filenames.get(prefix + "-" + fn);
//
String key = prefix.replace("-", "/") + "/" + dist2load; // String key = prefix.replace("-", "/") + "/" + dist2load;
//
byte[] s = outer.hget("dump".getBytes(), key.getBytes()); // byte[] s = outer.hget("dump".getBytes(), key.getBytes());
HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(s); // HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(s);
//
tree = getShapeTree(actionSet); // tree = getShapeTree(actionSet);
//
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
return tree; // return tree;
//
} // }
public static ITree getShapeTree(HierarchicalActionSet actionSet) { public static ITree getShapeTree(HierarchicalActionSet actionSet) {
ITree tree = null; ITree tree = null;
@@ -349,38 +338,38 @@ public class EDiffHelper {
return null; return null;
} }
public static Pair<ITree,HierarchicalActionSet> getActions(String prefix, String fn, JedisPool outerPool, HashMap<String, String> filenames) { // public static Pair<ITree,HierarchicalActionSet> getActions(String prefix, String fn, JedisPool outerPool, HashMap<String, String> filenames) {
//
//
ITree tree = null; // ITree tree = null;
HierarchicalActionSet actionSet = null; // HierarchicalActionSet actionSet = null;
//
try (Jedis outer = outerPool.getResource()) { // try (Jedis outer = outerPool.getResource()) {
try { // try {
while (!outer.ping().equals("PONG")) { // while (!outer.ping().equals("PONG")) {
log.info("wait"); // log.info("wait");
} // }
//
//
String dist2load = filenames.get(prefix + "-" + fn); // String dist2load = filenames.get(prefix + "-" + fn);
//
String[] split = prefix.split("-"); // String[] split = prefix.split("-");
String key = split[0] + "/"+split[1]+"/" + dist2load; // String key = split[0] + "/"+split[1]+"/" + dist2load;
//
byte[] s = outer.hget("dump".getBytes(), key.getBytes()); // byte[] s = outer.hget("dump".getBytes(), key.getBytes());
actionSet = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(s); // actionSet = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(s);
//
//
tree = getActionTrees(actionSet); // tree = getActionTrees(actionSet);
}catch (Exception e) { // }catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
//
Pair<ITree, HierarchicalActionSet> pair = new Pair<>(tree,actionSet); // Pair<ITree, HierarchicalActionSet> pair = new Pair<>(tree,actionSet);
return pair; // return pair;
//
} // }
public static ITree getActionTrees(HierarchicalActionSet actionSet) { public static ITree getActionTrees(HierarchicalActionSet actionSet) {
ITree tree = null; ITree tree = null;
@@ -406,41 +395,41 @@ public class EDiffHelper {
} }
} }
public static ITree getTokens(String prefix, String fn, JedisPool outerPool, HashMap<String, String> filenames) { // public static ITree getTokens(String prefix, String fn, JedisPool outerPool, HashMap<String, String> filenames) {
//
//
ITree tree = null; // ITree tree = null;
//
HierarchicalActionSet actionSet = null; // HierarchicalActionSet actionSet = null;
try (Jedis outer = outerPool.getResource()) { // try (Jedis outer = outerPool.getResource()) {
try { // try {
while (!outer.ping().equals("PONG")) { // while (!outer.ping().equals("PONG")) {
log.info("wait"); // log.info("wait");
} // }
String dist2load = filenames.get(prefix + "-" + fn); // String dist2load = filenames.get(prefix + "-" + fn);
//
String[] split = prefix.split("-"); // String[] split = prefix.split("-");
String key = split[0] + "/"+split[1]+"/" + dist2load; // String key = split[0] + "/"+split[1]+"/" + dist2load;
//
byte[] s = outer.hget("dump".getBytes(), key.getBytes()); // byte[] s = outer.hget("dump".getBytes(), key.getBytes());
actionSet = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(s); // actionSet = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(s);
//
ITree parent = null; // ITree parent = null;
ITree children = null; // ITree children = null;
TreeContext tc = new TreeContext(); // TreeContext tc = new TreeContext();
tree = EDiffHelper.getTokenTree(actionSet, parent, children, tc); // tree = EDiffHelper.getTokenTree(actionSet, parent, children, tc);
tree.setParent(null); // tree.setParent(null);
tc.validate(); // tc.validate();
// getLeaves(tree); //// getLeaves(tree);
//
//
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
//
return tree; // return tree;
} // }
+4 -4
View File
@@ -8,11 +8,11 @@ hostname = localhost
hunkLimit = 10 hunkLimit = 10
#inputPath = /Users/anilkoyuncu/projects/gumInputLinux #inputPath = /Users/anilkoyuncu/projects/gumInputLinux
inputPath = /Users/anilkoyuncu/projects/fixminer/fixminer-core/python/data/gumInputLinux inputPath = /Users/anil.koyuncu/projects/fixminer/fixminer-data/gumInputLinux
#redisPath = /Users/anil.koyuncu/projects/fixminer/fixminer-core/python/data/redis #redisPath = /Users/anil.koyuncu/projects/fixminer/fixminer-core/python/data/redis
redisPath = /Users/anilkoyuncu/projects/fixminer/fixminer-core/python/data/redis redisPath = /Users/anil.koyuncu/projects/fixminer/fixminer-core/python/data/redis
#srcMLPath= /Users/anil.koyuncu/Downloads/srcML/src2srcml srcMLPath= /Users/anil.koyuncu/Downloads/srcML.0.9.5/bin/srcml
srcMLPath= /usr/local/bin/srcml #srcMLPath= /usr/local/bin/srcml
actionType = ALL actionType = ALL
eDiffTimeout = 900 eDiffTimeout = 900