removed correcting iterator

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1920 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent 526407f32e
commit d5f8f40c31

@ -393,12 +393,12 @@ public final class plasmaWordIndex {
public Iterator wordHashes(String startHash, int resourceLevel, boolean rot) throws IOException { public Iterator wordHashes(String startHash, int resourceLevel, boolean rot) throws IOException {
if (rot) return new rotatingWordIterator(startHash, resourceLevel); 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) { if (resourceLevel == plasmaWordIndex.RL_RAMCACHE) {
return ramCache.wordHashes(startWordHash, rot); return ramCache.wordHashes(startWordHash, false);
} }
/* /*
if (resourceLevel == plasmaWordIndex.RL_FILECACHE) { if (resourceLevel == plasmaWordIndex.RL_FILECACHE) {
@ -407,16 +407,16 @@ public final class plasmaWordIndex {
*/ */
if (resourceLevel == plasmaWordIndex.RL_ASSORTMENTS) { if (resourceLevel == plasmaWordIndex.RL_ASSORTMENTS) {
return new kelondroMergeIterator( return new kelondroMergeIterator(
ramCache.wordHashes(startWordHash, rot), ramCache.wordHashes(startWordHash, false),
assortmentCluster.hashConjunction(startWordHash, true, rot), assortmentCluster.hashConjunction(startWordHash, true, false),
kelondroNaturalOrder.naturalOrder, kelondroNaturalOrder.naturalOrder,
true); true);
} }
if (resourceLevel == plasmaWordIndex.RL_WORDFILES) { if (resourceLevel == plasmaWordIndex.RL_WORDFILES) {
return new kelondroMergeIterator( return new kelondroMergeIterator(
new kelondroMergeIterator( new kelondroMergeIterator(
ramCache.wordHashes(startWordHash, rot), ramCache.wordHashes(startWordHash, false),
assortmentCluster.hashConjunction(startWordHash, true, rot), assortmentCluster.hashConjunction(startWordHash, true, false),
kelondroNaturalOrder.naturalOrder, kelondroNaturalOrder.naturalOrder,
true), true),
backend.wordHashes(startWordHash, true, false), backend.wordHashes(startWordHash, true, false),
@ -426,64 +426,13 @@ public final class plasmaWordIndex {
return null; 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 { private class rotatingWordIterator implements Iterator {
Iterator i; Iterator i;
int resourceLevel; int resourceLevel;
public rotatingWordIterator(String startWordHash, int resourceLevel) throws IOException { public rotatingWordIterator(String startWordHash, int resourceLevel) throws IOException {
this.resourceLevel = resourceLevel; this.resourceLevel = resourceLevel;
i = new correctedWordIterator(startWordHash, resourceLevel, false); i = wordHashes(startWordHash, resourceLevel);
} }
public void finalize() { public void finalize() {
@ -493,7 +442,7 @@ public final class plasmaWordIndex {
public boolean hasNext() { public boolean hasNext() {
if (i.hasNext()) return true; if (i.hasNext()) return true;
else try { else try {
i = new correctedWordIterator("------------", resourceLevel, false); i = wordHashes("------------", resourceLevel);
return i.hasNext(); return i.hasNext();
} catch (IOException e) { } catch (IOException e) {
return false; return false;

Loading…
Cancel
Save