latest change
This commit is contained in:
@@ -138,6 +138,18 @@
|
||||
<version>2.4</version>
|
||||
</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>
|
||||
|
||||
@@ -180,3 +192,8 @@
|
||||
</plugins>
|
||||
</build>
|
||||
</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";
|
||||
dumpsName = "dumps-"+pjName+".rdb";
|
||||
int iCursor = Integer.valueOf(cursor);
|
||||
// jobType = "CACHE";
|
||||
|
||||
try {
|
||||
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/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[] listOfFiles = folder.listFiles();
|
||||
Stream<File> stream = Arrays.stream(listOfFiles);
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+137
-120
@@ -23,6 +23,7 @@ import redis.clients.jedis.JedisPool;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static edu.lu.uni.serval.fixminer.jobs.MultiThreadTreeLoaderCluster3.getNames;
|
||||
|
||||
@@ -52,15 +53,15 @@ public class CompareTrees {
|
||||
log.info(cmdInner);
|
||||
cs.runShell(cmdInner, portInner);
|
||||
|
||||
String numOfWorkers = args[4];
|
||||
String host = args[5];
|
||||
String numOfWorkers = "100000000";//args[4];
|
||||
String host = "localhost";//args[5];
|
||||
// -Djava.util.concurrent.ForkJoinPool.common.parallelism=256
|
||||
|
||||
final JedisPool innerPool = new JedisPool(PoolBuilder.getPoolConfig(), host,Integer.valueOf(portInner),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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
// for (String listOfPair : listOfPairs) {
|
||||
@@ -119,25 +141,19 @@ public class CompareTrees {
|
||||
// }.counter;
|
||||
// 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 newTree = null;
|
||||
Pair<ITree, HierarchicalActionSet> oldPair = null;
|
||||
Pair<ITree, HierarchicalActionSet> newPair = null;
|
||||
String matchKey = null;
|
||||
|
||||
try {
|
||||
jedis = innerPool.getResource();
|
||||
|
||||
String[] split = pairName.split("_");
|
||||
|
||||
@@ -145,6 +161,15 @@ public class CompareTrees {
|
||||
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);
|
||||
|
||||
switch (treeType) {
|
||||
case "shape":
|
||||
@@ -162,18 +187,10 @@ public class CompareTrees {
|
||||
case "token":
|
||||
oldTree = EDiffHelper.getTokens(keyName, i, 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);
|
||||
|
||||
|
||||
// CharSequence[] oldSequences = oldTokens.toArray(new CharSequence[oldTokens.size()]);
|
||||
// CharSequence[] newSequences = newTokens.toArray(new CharSequence[newTokens.size()]);
|
||||
JaroWinklerDistance jwd = new JaroWinklerDistance();
|
||||
|
||||
|
||||
@@ -183,31 +200,28 @@ public class CompareTrees {
|
||||
overallSimi = jwd.apply(oldTokens, newTokens);
|
||||
|
||||
}
|
||||
// if(oldSequences.length > 0 && (oldSequences.length == newSequences.length)){
|
||||
// for (int idx = 0; idx < newSequences.length; idx++) {
|
||||
// Double simi = jwd.apply(newSequences[idx], oldSequences[idx]);
|
||||
// overallSimi = simi + overallSimi;
|
||||
// }
|
||||
// overallSimi = overallSimi / oldSequences.length;
|
||||
// }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);
|
||||
try (Jedis jedis = innerPool.getResource()) {
|
||||
// jedis.del(matchKey);
|
||||
jedis.select(2);
|
||||
jedis.set(matchKey, result);
|
||||
}
|
||||
jedis.select(0);
|
||||
jedis.srem("pairs",matchKey);
|
||||
// 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;
|
||||
@@ -215,103 +229,106 @@ public class CompareTrees {
|
||||
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;
|
||||
if(oldTree.toStaticHashString().equals(newTree.toStaticHashString())){
|
||||
String editDistance = "0";
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
jedis.select(0);
|
||||
jedis.srem("pairs",matchKey);
|
||||
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);
|
||||
// e.printStackTrace();
|
||||
// throw e;
|
||||
|
||||
|
||||
}finally {
|
||||
if (jedis != null) {
|
||||
jedis.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Regular → Executable
+1
-1
@@ -20,6 +20,6 @@ public class RunnableCompare implements Runnable {
|
||||
|
||||
@Override
|
||||
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()) {
|
||||
|
||||
inner.set(key, EDiffHelper.toString(actionSet));
|
||||
inner.set(key.getBytes(), EDiffHelper.toByteArray(actionSet));
|
||||
}
|
||||
|
||||
} 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.EDiffHelper;
|
||||
import edu.lu.uni.serval.utils.PoolBuilder;
|
||||
import org.redisson.Redisson;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import redis.clients.jedis.Jedis;
|
||||
@@ -137,7 +139,7 @@ public class StoreEDiffInCache {
|
||||
|
||||
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);
|
||||
// writeTofFile(shapesFolder, outerPool);
|
||||
|
||||
File file = new File(shapesFolder);
|
||||
|
||||
|
||||
File[] files = file.listFiles();
|
||||
ArrayList<String> strings = new ArrayList<>();
|
||||
List<File> folders = Arrays.stream(files).filter(x -> x.isDirectory())
|
||||
.collect(Collectors.toList());
|
||||
for (File target : folders) {
|
||||
File[] files2 = target.listFiles();
|
||||
for (File file1 : files2) {
|
||||
File[] files1 = file1.listFiles();
|
||||
strings.add(((File)files1[0]).listFiles()[0].getName());
|
||||
// System.out.println();
|
||||
|
||||
}
|
||||
|
||||
// Collection<File> files1 = FileUtils.listFiles(target, null, true);
|
||||
|
||||
}
|
||||
|
||||
for (String string : strings) {
|
||||
export("*"+string,jedis);
|
||||
}
|
||||
// File file = new File(shapesFolder);
|
||||
//
|
||||
//
|
||||
// File[] files = file.listFiles();
|
||||
// ArrayList<String> strings = new ArrayList<>();
|
||||
// List<File> folders = Arrays.stream(files).filter(x -> x.isDirectory())
|
||||
// .collect(Collectors.toList());
|
||||
// for (File target : folders) {
|
||||
// File[] files2 = target.listFiles();
|
||||
// for (File file1 : files2) {
|
||||
// File[] files1 = file1.listFiles();
|
||||
// strings.add(((File)files1[0]).listFiles()[0].getName());
|
||||
//// System.out.println();
|
||||
//
|
||||
// }
|
||||
//
|
||||
//// Collection<File> files1 = FileUtils.listFiles(target, null, true);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// for (String string : strings) {
|
||||
// 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(args[0], jedis);
|
||||
// System.out.println(export);
|
||||
String export = export(args[0], jedis);
|
||||
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();
|
||||
// Jedis outer = outerPool.getResource();
|
||||
@@ -64,30 +64,31 @@ public class ClusterToPattern {
|
||||
throw new Error("cok key");
|
||||
}
|
||||
|
||||
String si = outer.get(s);
|
||||
HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.fromString(si);
|
||||
ITree tree = null;
|
||||
ITree parent = null;
|
||||
ITree children =null;
|
||||
TreeContext tc = new TreeContext();
|
||||
tree = EDiffHelper.getASTTree(actionSet, parent, children,tc);
|
||||
tree.setParent(null);
|
||||
tc.validate();
|
||||
byte[] si = outer.get(s.getBytes());
|
||||
// HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.fromString(si);
|
||||
HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.fromByteArray(si);
|
||||
// ITree tree = null;
|
||||
// ITree parent = null;
|
||||
// ITree children =null;
|
||||
// TreeContext tc = new TreeContext();
|
||||
// tree = EDiffHelper.getASTTree(actionSet, parent, children,tc);
|
||||
// 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();
|
||||
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 s1 = actionSet.toString();
|
||||
// outer.close();
|
||||
// return s1;
|
||||
String s1 = actionSet.toString();
|
||||
outer.close();
|
||||
return s1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Regular → Executable
+83
-49
@@ -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){
|
||||
|
||||
int newType = 0;
|
||||
@@ -230,19 +248,22 @@ public class EDiffHelper {
|
||||
public static ITree getShapes(String prefix, String fn, JedisPool outerPool,JedisPool innerPool) {
|
||||
|
||||
ITree tree = null;
|
||||
Jedis inner = null;
|
||||
Jedis outer = null;
|
||||
// Jedis inner = null;
|
||||
// Jedis outer = null;
|
||||
try (Jedis inner = innerPool.getResource(); Jedis outer = outerPool.getResource()) {
|
||||
// inner = innerPool.getResource();
|
||||
try {
|
||||
inner = innerPool.getResource();
|
||||
while (!inner.ping().equals("PONG")) {
|
||||
log.info("wait");
|
||||
}
|
||||
inner.select(1);
|
||||
String dist2load = inner.get(prefix + "-" + fn);
|
||||
outer = outerPool.getResource();
|
||||
|
||||
// outer = outerPool.getResource();
|
||||
outer.select(0);
|
||||
String s = outer.get(prefix.replace("-","/") +"/"+dist2load);
|
||||
HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.fromString(s);
|
||||
String key = prefix.replace("-", "/") + "/" + dist2load;
|
||||
byte[] s = outer.get(key.getBytes());
|
||||
HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.fromByteArray(s);
|
||||
|
||||
ITree parent = null;
|
||||
ITree children = null;
|
||||
@@ -255,14 +276,16 @@ public class EDiffHelper {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -381,28 +404,31 @@ public class EDiffHelper {
|
||||
|
||||
try {
|
||||
String dist2load = null;
|
||||
String si = null;
|
||||
try (Jedis inner = innerPool.getResource()){
|
||||
byte[] si = null;
|
||||
try (Jedis inner = innerPool.getResource();Jedis outer = outerPool.getResource()){
|
||||
|
||||
inner.select(1);
|
||||
dist2load = inner.get(prefix + "-" + firstValue);
|
||||
}
|
||||
try(Jedis outer = outerPool.getResource()) {
|
||||
outer.select(0);
|
||||
String s = null;//inner.get(prefix.replace("-","/") +"/"+dist2load);
|
||||
Set<String> keys = outer.keys(prefix.split("-")[0] + "/*/" + dist2load);
|
||||
if (keys.size() == 1) {
|
||||
s = (String) keys.toArray()[0];
|
||||
} else {
|
||||
throw new Error("cok key");
|
||||
}
|
||||
si = outer.get(s);
|
||||
}
|
||||
|
||||
outer.select(0);
|
||||
String[] split = prefix.split("-");
|
||||
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;
|
||||
// if (keys.size() == 1) {
|
||||
// s = (String) keys.toArray()[0];
|
||||
// } else {
|
||||
// throw new Error("cok key");
|
||||
// }
|
||||
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;
|
||||
actionSet = (HierarchicalActionSet) EDiffHelper.fromString(si);
|
||||
|
||||
// actionSet = (HierarchicalActionSet) EDiffHelper.fromString(si);
|
||||
}
|
||||
|
||||
ITree parent = null;
|
||||
ITree children = null;
|
||||
@@ -439,28 +465,33 @@ public class EDiffHelper {
|
||||
|
||||
|
||||
ITree tree = null;
|
||||
Jedis inner = null;
|
||||
Jedis outer = null;
|
||||
|
||||
// Jedis inner = null;
|
||||
// Jedis outer = null;
|
||||
|
||||
try{
|
||||
inner = innerPool.getResource();
|
||||
try (Jedis inner = innerPool.getResource();Jedis outer = outerPool.getResource()) {
|
||||
// inner = innerPool.getResource();
|
||||
inner.select(1);
|
||||
String dist2load = inner.get(prefix + "-" + firstValue);
|
||||
outer = outerPool.getResource();
|
||||
// outer = outerPool.getResource();
|
||||
outer.select(0);
|
||||
String s = null;//inner.get(prefix.replace("-","/") +"/"+dist2load);
|
||||
Set<String> keys = outer.keys(prefix.split("-")[0] + "/*/" + dist2load);
|
||||
if (keys.size() == 1) {
|
||||
s = (String) keys.toArray()[0];
|
||||
} else {
|
||||
throw new Error("cok key");
|
||||
}
|
||||
// String s = null;//inner.get(prefix.replace("-","/") +"/"+dist2load);
|
||||
// Set<String> keys = outer.keys(prefix.split("-")[0] + "/*/" + dist2load);
|
||||
// if (keys.size() == 1) {
|
||||
// s = (String) keys.toArray()[0];
|
||||
// } else {
|
||||
// throw new Error("cok key");
|
||||
// }
|
||||
|
||||
|
||||
// String filename = project + "/"+type+"/" + pureFileName + ".txt_" + actionSetPosition;
|
||||
String si = outer.get(s);
|
||||
HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.fromString(si);
|
||||
String[] split = prefix.split("-");
|
||||
// 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;
|
||||
@@ -470,21 +501,24 @@ public class EDiffHelper {
|
||||
tree.setParent(null);
|
||||
tc.validate();
|
||||
// getLeaves(tree);
|
||||
}
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Regular → Executable
+3
@@ -15,6 +15,9 @@ public class PoolBuilder {
|
||||
static final JedisPoolConfig poolConfig = buildPoolConfig();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private static JedisPoolConfig buildPoolConfig() {
|
||||
final JedisPoolConfig poolConfig = new JedisPoolConfig();
|
||||
poolConfig.setMaxTotal(1024);
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Reference in New Issue
Block a user