From 56936139ae5f676213942f251052e25d4b2c7a53 Mon Sep 17 00:00:00 2001 From: hermens Date: Tue, 31 Jan 2006 02:01:32 +0000 Subject: [PATCH] Fix logging in kelondroTree: *) Use java.util.logging.* (via kelondroRecords) without de.anomic.server.logging.serverLog *) Log "CORRECTING ITERATOR" only in debug mode (happens way too often to be a useful warning and is corrected anyway) *) Log when correctedNodeIterator stumbles on incorrectly ordered data (now this one deserves throwing a warning at the user) git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1503 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/kelondro/kelondroRecords.java | 7 +++++++ source/de/anomic/kelondro/kelondroTree.java | 14 ++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/source/de/anomic/kelondro/kelondroRecords.java b/source/de/anomic/kelondro/kelondroRecords.java index 1e0fb6e58..9fc35bf48 100644 --- a/source/de/anomic/kelondro/kelondroRecords.java +++ b/source/de/anomic/kelondro/kelondroRecords.java @@ -330,6 +330,13 @@ public class kelondroRecords { this.theLogger.severe("KELONDRO FAILURE for file " + this.filename + ": " + message); } + public void logFine(String message) { + if (this.theLogger == null) + System.out.println("KELONDRO DEBUG for file " + this.filename + ": " + message); + else + this.theLogger.fine("KELONDRO DEBUG for file " + this.filename + ": " + message); + } + public void clear() throws IOException { // Removes all mappings from this map // throw new UnsupportedOperationException("clear not supported"); diff --git a/source/de/anomic/kelondro/kelondroTree.java b/source/de/anomic/kelondro/kelondroTree.java index 96e5a25bb..370123342 100644 --- a/source/de/anomic/kelondro/kelondroTree.java +++ b/source/de/anomic/kelondro/kelondroTree.java @@ -56,12 +56,12 @@ import java.util.LinkedList; import java.util.StringTokenizer; import java.util.TreeSet; import java.util.Vector; -import de.anomic.server.logging.serverLog; +import java.util.logging.Logger; public class kelondroTree extends kelondroRecords implements kelondroIndex { - //logging [Should be replaced to be able to split DB|YaCy - delete this, delete import, delete before "correcting iterator" message] - public static serverLog log; + // logging (This probably needs someone to initialize the java.util.logging.* facilities); + public static Logger log = Logger.getLogger("KELONDRO"); // define the Over-Head-Array private static short thisOHBytes = 2; // our record definition of two bytes @@ -107,6 +107,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex { } this.objectOrder = objectOrder; writeOrderType(); + super.setLogger(log); } public kelondroTree(kelondroRA ra, long buffersize, int[] columns, boolean exitOnFail) { @@ -127,18 +128,21 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex { } this.objectOrder = objectOrder; writeOrderType(); + super.setLogger(log); } public kelondroTree(File file, long buffersize) throws IOException { // this opens a file with an existing tree file super(file, buffersize); readOrderType(); + super.setLogger(log); } public kelondroTree(kelondroRA ra, long buffersize) throws IOException { // this opens a file with an existing tree in a kelondroRA super(ra, buffersize); readOrderType(); + super.setLogger(log); } private void writeOrderType() { @@ -854,10 +858,11 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex { int c = objectOrder.compare(firstKey, nextNode.getKey()); if ((c > 0) && (asc)) { // firstKey > nextNode.getKey() - if (log != null) log.logWarning("CORRECTING ITERATOR: firstKey=" + new String(firstKey) + ", nextNode=" + new String(nextNode.getKey())); + logFine("CORRECTING ITERATOR: firstKey=" + new String(firstKey) + ", nextNode=" + new String(nextNode.getKey())); nextNode = (ii.hasNext()) ? (Node) ii.next() : null; } if ((c < 0) && (!(asc))) { + logFine("CORRECTING ITERATOR: firstKey=" + new String(firstKey) + ", nextNode=" + new String(nextNode.getKey())); nextNode = (ii.hasNext()) ? (Node) ii.next() : null; } } @@ -877,6 +882,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex { nextNode = (ii.hasNext()) ? (Node) ii.next() : null; if ((nextNode != null) && (asc == (objectOrder.compare(r, nextNode) == 1))) { // correct wrong order (this should not happen) + logWarning("STOPPING ITERATOR: currentNode=" + new String(r.getKey()) + ", nextNode=" + new String(nextNode.getKey())); if (rot) { try { ii = new nodeIterator(asc, rot);