This commit is contained in:
fixminer
2020-01-20 12:36:40 +01:00
parent 2cd0783300
commit c8dfd0e21b
2 changed files with 25 additions and 22 deletions
@@ -7,10 +7,7 @@ import redis.clients.jedis.JedisPool;
import redis.clients.jedis.ScanParams; import redis.clients.jedis.ScanParams;
import redis.clients.jedis.ScanResult; import redis.clients.jedis.ScanResult;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -87,13 +84,14 @@ public class AkkaTreeParser {
} }
// inner.select(1); // inner.select(1);
Map<String, String> filenames = inner.hgetAll("compare"); Set<String> compare = inner.hkeys("compare");
// compare.size();
result= new ArrayList<String>(compare);
// for (Map.Entry<String, String> stringStringEntry : filenames.entrySet().stream().collect(Collectors.toList())) {
for (Map.Entry<String, String> stringStringEntry : filenames.entrySet().stream().collect(Collectors.toList())) { //// fileMap.put(stringStringEntry.getKey(),stringStringEntry.getValue());
// fileMap.put(stringStringEntry.getKey(),stringStringEntry.getValue()); // result.add(stringStringEntry.getKey());
result.add(stringStringEntry.getKey()); // }
}
@@ -103,20 +103,21 @@ public class CompareTrees {
@Override @Override
public void run() { public void run() {
int dbsize = 1; // int dbsize = 1;
while(dbsize>0) { boolean stop = true;
try (Jedis outer = outerPool.getResource()) { while(stop) {
dbsize = Math.toIntExact(outer.scard("compare")); // try (Jedis outer = outerPool.getResource()) {
} // dbsize = Math.toIntExact(outer.scard("compare"));
if (dbsize != 0){ // }
newCoreCompare(job, errorPairs, filenames, outerPool); // if (dbsize != 0){
} stop = newCoreCompare(job, errorPairs, filenames, outerPool);
// }
} }
} }
} }
public static void newCoreCompare( String treeType,ArrayList<String> errorPairs, HashMap<String, String> filenames,JedisPool outerPool ) { public static boolean newCoreCompare( String treeType,ArrayList<String> errorPairs, HashMap<String, String> filenames,JedisPool outerPool ) {
String pairName; String pairName;
try (Jedis outer = outerPool.getResource()) { try (Jedis outer = outerPool.getResource()) {
@@ -138,7 +139,7 @@ public class CompareTrees {
case "single": case "single":
if (matchKey == null){ if (matchKey == null){
System.out.println(); return false;
} }
Map<String, String> oldTreeString = EDiffHelper.getTreeString(keyName, i, outerPool, filenames); Map<String, String> oldTreeString = EDiffHelper.getTreeString(keyName, i, outerPool, filenames);
Map<String, String> newTreeString = EDiffHelper.getTreeString(keyName, j, outerPool, filenames); Map<String, String> newTreeString = EDiffHelper.getTreeString(keyName, j, outerPool, filenames);
@@ -165,16 +166,20 @@ public class CompareTrees {
} }
} }
} }
return; return true;
default: default:
break; return true;
// break;
} }
}catch (Exception e) { }catch (Exception e) {
errorPairs.add(matchKey); errorPairs.add(matchKey);
if (pairName == null)
return false;
log.debug("{} not comparable", pairName); log.debug("{} not comparable", pairName);
} }
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 ) {