From d5f8f40c31977b1fcf9379aaa2aee92a3933dc23 Mon Sep 17 00:00:00 2001 From: orbiter Date: Sat, 18 Mar 2006 01:01:00 +0000 Subject: [PATCH] removed correcting iterator git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1920 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/plasma/plasmaWordIndex.java | 69 +++----------------- 1 file changed, 9 insertions(+), 60 deletions(-) diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.java index b8d201ada..5f421f9b8 100644 --- a/source/de/anomic/plasma/plasmaWordIndex.java +++ b/source/de/anomic/plasma/plasmaWordIndex.java @@ -393,12 +393,12 @@ public final class plasmaWordIndex { public Iterator wordHashes(String startHash, int resourceLevel, boolean rot) throws IOException { if (rot) return new rotatingWordIterator(startHash, resourceLevel); - else return new correctedWordIterator(startHash, resourceLevel, rot); // use correction until bug is found + else return wordHashes(startHash, resourceLevel); } - private Iterator wordHashesX(String startWordHash, int resourceLevel, boolean rot) throws IOException { + private Iterator wordHashes(String startWordHash, int resourceLevel) throws IOException { if (resourceLevel == plasmaWordIndex.RL_RAMCACHE) { - return ramCache.wordHashes(startWordHash, rot); + return ramCache.wordHashes(startWordHash, false); } /* if (resourceLevel == plasmaWordIndex.RL_FILECACHE) { @@ -407,16 +407,16 @@ public final class plasmaWordIndex { */ if (resourceLevel == plasmaWordIndex.RL_ASSORTMENTS) { return new kelondroMergeIterator( - ramCache.wordHashes(startWordHash, rot), - assortmentCluster.hashConjunction(startWordHash, true, rot), + ramCache.wordHashes(startWordHash, false), + assortmentCluster.hashConjunction(startWordHash, true, false), kelondroNaturalOrder.naturalOrder, true); } if (resourceLevel == plasmaWordIndex.RL_WORDFILES) { return new kelondroMergeIterator( new kelondroMergeIterator( - ramCache.wordHashes(startWordHash, rot), - assortmentCluster.hashConjunction(startWordHash, true, rot), + ramCache.wordHashes(startWordHash, false), + assortmentCluster.hashConjunction(startWordHash, true, false), kelondroNaturalOrder.naturalOrder, true), backend.wordHashes(startWordHash, true, false), @@ -426,64 +426,13 @@ public final class plasmaWordIndex { return null; } - - private final class correctedWordIterator implements Iterator { - Iterator iter; - String nextWord; - - public correctedWordIterator(String firstWord, int resourceLevel, boolean rotating) throws IOException { - iter = wordHashesX(firstWord, resourceLevel, rotating); - try { - nextWord = (iter.hasNext()) ? (String) iter.next() : null; - boolean corrected = true; - int cc = 0; // to avoid rotation loops - while ((nextWord != null) && (corrected) && (cc < 50)) { - int c = firstWord.compareTo(nextWord); - corrected = false; - if (c > 0) { - // firstKey > nextNode.getKey() - //System.out.println("CORRECTING WORD ITERATOR: firstWord=" + firstWord + ", nextWord=" + nextWord); - nextWord = (iter.hasNext()) ? (String) iter.next() : null; - corrected = true; - cc++; - } - } - } catch (java.util.ConcurrentModificationException e) { - nextWord = null; - } - } - - public void finalize() { - iter = null; - nextWord = null; - } - - public boolean hasNext() { - return nextWord != null; - } - - public Object next() { - String r = nextWord; - try { - nextWord = (iter.hasNext()) ? (String) iter.next() : null; - } catch (java.util.ConcurrentModificationException e) { - nextWord = null; - } - return r; - } - - public void remove() { - throw new java.lang.UnsupportedOperationException("correctedWordIterator does not support remove"); - } - } // correctedWordIterator - private class rotatingWordIterator implements Iterator { Iterator i; int resourceLevel; public rotatingWordIterator(String startWordHash, int resourceLevel) throws IOException { this.resourceLevel = resourceLevel; - i = new correctedWordIterator(startWordHash, resourceLevel, false); + i = wordHashes(startWordHash, resourceLevel); } public void finalize() { @@ -493,7 +442,7 @@ public final class plasmaWordIndex { public boolean hasNext() { if (i.hasNext()) return true; else try { - i = new correctedWordIterator("------------", resourceLevel, false); + i = wordHashes("------------", resourceLevel); return i.hasNext(); } catch (IOException e) { return false;