tried to fix 100% CPU bug.

See http://www.yacy-forum.de/viewtopic.php?p=15569#15569

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1393 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 20 years ago
parent f14d49fae9
commit 7366e39dd3

@ -208,9 +208,9 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
// a search object combines the results of a search in the tree, which are // a search object combines the results of a search in the tree, which are
// - the searched object is found, an index pointing to the node can be returned // - the searched object is found, an index pointing to the node can be returned
// - the object was not found, an index pointing to an appropriate possible parent node can // - the object was not found, an index pointing to an appropriate possible parent node
// be returned, together with the information wether the new key shall be left or right child. // can be returned, together with the information wether the new key shall
// // be left or right child.
private Node thenode, parentnode; private Node thenode, parentnode;
private boolean found; // property if node was found private boolean found; // property if node was found
@ -240,7 +240,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
child = 0; child = 0;
found = false; found = false;
int c; int c;
HashMap visitedNodeKeys = new HashMap(); // to detect loops HashSet visitedNodeKeys = new HashSet(); // to detect loops
String otherkey; 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) {
@ -258,10 +258,9 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
try { try {
otherkey = new String(thenode.getKey()); otherkey = new String(thenode.getKey());
} catch (NullPointerException e) { } catch (NullPointerException e) {
throw new kelondroException(filename, "kelondroTree.Search.process: nullpointer" + e.getMessage() + throw new kelondroException(filename, "kelondroTree.Search.process: nullpointer" + e.getMessage() + "\nNode: " + thenode.toString());
"\nNode: " + thenode.toString());
} }
if (visitedNodeKeys.containsKey(otherkey)) { 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);
@ -271,23 +270,21 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
thenode.setOHHandle(rightchild, null); thenode.setOHHandle(rightchild, null);
thenode.commit(CP_NONE); thenode.commit(CP_NONE);
/* /*
Iterator fix = visitedNodeKeys.entrySet().iterator(); * Iterator fix = visitedNodeKeys.entrySet().iterator();
Map.Entry entry; * Map.Entry entry; while (fix.hasNext()) { entry =
while (fix.hasNext()) { * (Map.Entry) fix.next(); thenode = (Node)
entry = (Map.Entry) fix.next(); * entry.getValue(); thenode.setOHByte(magic, (byte) 1);
thenode = (Node) entry.getValue(); * thenode.setOHByte(balance, (byte) 0);
thenode.setOHByte(magic, (byte) 1); * thenode.setOHHandle(parent, null);
thenode.setOHByte(balance, (byte) 0); * thenode.setOHHandle(leftchild, null);
thenode.setOHHandle(parent, null); * thenode.setOHHandle(rightchild, null); }
thenode.setOHHandle(leftchild, null);
thenode.setOHHandle(rightchild, null);
}
*/ */
logWarning("kelondroTree.Search.process: database contains loops; the loop-nodes have been auto-fixed"); logWarning("kelondroTree.Search.process: database contains loops; the loop-nodes have been auto-fixed");
found = false; found = false;
return; return;
} }
//System.out.println("Comparing key = '" + new String(key) + "' with '" + otherkey + "':"); // debug // System.out.println("Comparing key = '" + new String(key)
// + "' with '" + otherkey + "':"); // debug
c = objectOrder.compare(key, thenode.getKey()); c = objectOrder.compare(key, thenode.getKey());
// System.out.println(c); // debug // System.out.println(c); // debug
if (c == 0) { if (c == 0) {
@ -301,10 +298,14 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
child = 1; child = 1;
thisHandle = thenode.getOHHandle(rightchild); thisHandle = thenode.getOHHandle(rightchild);
} }
visitedNodeKeys.put(otherkey, thenode); visitedNodeKeys.add(otherkey);
} }
} }
//System.out.println("DEBUG: search for " + new String(key) + " ended with status=" + ((found) ? "found" : "not-found") + ", node=" + ((thenode == null) ? "NULL" : thenode.toString()) + ", parent=" + ((parentnode == null) ? "NULL" : parentnode.toString())); // System.out.println("DEBUG: search for " + new String(key) + "
// ended with status=" + ((found) ? "found" : "not-found") + ",
// node=" + ((thenode == null) ? "NULL" : thenode.toString()) + ",
// parent=" + ((parentnode == null) ? "NULL" :
// parentnode.toString()));
// we reached a node where we must insert the new value // we reached a node where we must insert the new value
// the parent of this new value can be obtained by getParent() // the parent of this new value can be obtained by getParent()
// all values are set, just return // all values are set, just return

@ -101,7 +101,7 @@ public final class plasmaWordIndexAssortmentCluster {
if (newContainer.size() > clusterCount) return newContainer; // it will not fit if (newContainer.size() > clusterCount) return newContainer; // it will not fit
plasmaWordIndexEntryContainer buffer; plasmaWordIndexEntryContainer buffer;
while ((buffer = assortments[newContainer.size() - 1].remove(wordHash)) != null) { while ((buffer = assortments[newContainer.size() - 1].remove(wordHash)) != null) {
newContainer.add(buffer); if (newContainer.add(buffer) == 0) return newContainer; // security check; othervise this loop does not terminate
if (newContainer.size() > clusterCount) return newContainer; // it will not fit if (newContainer.size() > clusterCount) return newContainer; // it will not fit
} }
// the assortment (newContainer.size() - 1) should now be empty. put it in there // the assortment (newContainer.size() - 1) should now be empty. put it in there

Loading…
Cancel
Save