Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

added patch to correct tree-iterator (symptoms: at the end of the iteration, more elements are iterated that are not in the correct order)

orbiterc137683a5ccc
diff --git a/source/de/anomic/kelondro/kelondroTree.java b/source/de/anomic/kelondro/kelondroTree.java
index 3631ad333..587a37b8e 100644
--- a/source/de/anomic/kelondro/kelondroTree.java
+++ b/source/de/anomic/kelondro/kelondroTree.java
@@ -815,8 +815,10 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
Iterator ii;
Node nextNode;
+ boolean asc;
public correctedNodeIterator(boolean up, boolean rotating, Node start, byte[] firstKey) throws IOException {
+ asc = up;
ii = new nodeIterator(up, rotating, start);
nextNode = (ii.hasNext()) ? (Node) ii.next() : null;
if (nextNode != null) {
@@ -837,13 +839,14 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
nextNode = null;
}
- public boolean hasNext() {
+ public boolean hasNext() {
return nextNode != null;
- }
+ }
public Object next() {
Node r = nextNode;
nextNode = (ii.hasNext()) ? (Node) ii.next() : null;
+ if ((nextNode != null) && (asc == (objectOrder.compare(r, nextNode) == 1))) nextNode = null; // correct wrong order (this should not happen)
return r;
}