replaced String object in loop detection by byte[] to omit String-generation

which could cause locks.
See http://www.yacy-forum.de/viewtopic.php?p=15738#15738

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1425 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent 927c2c3709
commit b9d73f63e7

@ -243,7 +243,7 @@ public final class kelondroMScoreCluster {
return (int) ((((Long) keyrefDB.lastKey()).longValue() & 0xFFFFFFFF00000000L) >> 32); return (int) ((((Long) keyrefDB.lastKey()).longValue() & 0xFFFFFFFF00000000L) >> 32);
} }
public int getMinScore() { public synchronized int getMinScore() {
if (refkeyDB.size() == 0) return -1; if (refkeyDB.size() == 0) return -1;
return (int) ((((Long) keyrefDB.firstKey()).longValue() & 0xFFFFFFFF00000000L) >> 32); return (int) ((((Long) keyrefDB.firstKey()).longValue() & 0xFFFFFFFF00000000L) >> 32);
} }

@ -54,6 +54,7 @@ import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.Vector; import java.util.Vector;
public class kelondroTree extends kelondroRecords implements kelondroIndex { public class kelondroTree extends kelondroRecords implements kelondroIndex {
@ -75,6 +76,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
private Search writeSearchObj = new Search(); private Search writeSearchObj = new Search();
private kelondroOrder objectOrder = new kelondroNaturalOrder(true); private kelondroOrder objectOrder = new kelondroNaturalOrder(true);
private final kelondroOrder loopDetectionOrder = new kelondroNaturalOrder(true);
public kelondroTree(File file, long buffersize, int key, int value, boolean exitOnFail) { public kelondroTree(File file, long buffersize, int key, int value, boolean exitOnFail) {
this(file, buffersize, new int[] { key, value }, new kelondroNaturalOrder(true), 1, 8, exitOnFail); this(file, buffersize, new int[] { key, value }, new kelondroNaturalOrder(true), 1, 8, exitOnFail);
@ -239,8 +241,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
child = 0; child = 0;
found = false; found = false;
int c; int c;
HashSet visitedNodeKeys = new HashSet(); // to detect loops TreeSet visitedNodeKeys = new TreeSet(loopDetectionOrder); // to detect loops
String otherkey;
// System.out.println("Starting Compare Loop in Database " + filename); // debug // System.out.println("Starting Compare Loop in Database " + filename); // debug
while (thisHandle != null) { while (thisHandle != null) {
try { try {
@ -254,12 +255,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
if (thenode == null) { if (thenode == null) {
throw new kelondroException(filename, "kelondroTree.Search.process: thenode==null"); throw new kelondroException(filename, "kelondroTree.Search.process: thenode==null");
} }
try { if (visitedNodeKeys.contains(thenode.getKey())) {
otherkey = new String(thenode.getKey());
} catch (NullPointerException e) {
throw new kelondroException(filename, "kelondroTree.Search.process: nullpointer" + e.getMessage() + "\nNode: " + thenode.toString());
}
if (visitedNodeKeys.contains(otherkey)) {
// we have loops in the database. // we have loops in the database.
// to fix this, all affected nodes must be patched // to fix this, all affected nodes must be patched
thenode.setOHByte(magic, (byte) 1); thenode.setOHByte(magic, (byte) 1);
@ -297,7 +293,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
child = 1; child = 1;
thisHandle = thenode.getOHHandle(rightchild); thisHandle = thenode.getOHHandle(rightchild);
} }
visitedNodeKeys.add(otherkey); visitedNodeKeys.add(thenode.getKey());
} }
} }
// System.out.println("DEBUG: search for " + new String(key) + " // System.out.println("DEBUG: search for " + new String(key) + "

Loading…
Cancel
Save