Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
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
orbiterb9d73f63e7fa
diff --git a/source/de/anomic/kelondro/kelondroMScoreCluster.java b/source/de/anomic/kelondro/kelondroMScoreCluster.javaindex 6c1396209..55649c7d3 100644--- a/source/de/anomic/kelondro/kelondroMScoreCluster.java+++ b/source/de/anomic/kelondro/kelondroMScoreCluster.java@@ -243,7 +243,7 @@ public final class kelondroMScoreCluster {return (int) ((((Long) keyrefDB.lastKey()).longValue() & 0xFFFFFFFF00000000L) >> 32);}- public int getMinScore() {+ public synchronized int getMinScore() {if (refkeyDB.size() == 0) return -1;return (int) ((((Long) keyrefDB.firstKey()).longValue() & 0xFFFFFFFF00000000L) >> 32);}diff --git a/source/de/anomic/kelondro/kelondroTree.java b/source/de/anomic/kelondro/kelondroTree.javaindex fdb3e20ae..49c9f537d 100644--- a/source/de/anomic/kelondro/kelondroTree.java+++ b/source/de/anomic/kelondro/kelondroTree.java@@ -54,6 +54,7 @@ import java.util.HashSet;import java.util.Iterator;import java.util.LinkedList;import java.util.StringTokenizer;+import java.util.TreeSet;import java.util.Vector;public class kelondroTree extends kelondroRecords implements kelondroIndex {@@ -75,6 +76,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {private Search writeSearchObj = new Search();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) {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;found = false;int c;- HashSet visitedNodeKeys = new HashSet(); // to detect loops- String otherkey;+ TreeSet visitedNodeKeys = new TreeSet(loopDetectionOrder); // to detect loops// System.out.println("Starting Compare Loop in Database " + filename); // debugwhile (thisHandle != null) {try {@@ -254,12 +255,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {if (thenode == null) {throw new kelondroException(filename, "kelondroTree.Search.process: thenode==null");}- try {- 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)) {+ if (visitedNodeKeys.contains(thenode.getKey())) {// we have loops in the database.// to fix this, all affected nodes must be patchedthenode.setOHByte(magic, (byte) 1);@@ -297,7 +293,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {child = 1;thisHandle = thenode.getOHHandle(rightchild);}- visitedNodeKeys.add(otherkey);+ visitedNodeKeys.add(thenode.getKey());}}// System.out.println("DEBUG: search for " + new String(key) + "