Skip to content

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

patch for http://forum.yacy-websuche.de/viewtopic.php?p=14720#p14720

orbiterb7457d3807df
diff --git a/source/de/anomic/kelondro/index/RowSet.java b/source/de/anomic/kelondro/index/RowSet.java
index 5deb740f7..abf5b3b45 100644
--- a/source/de/anomic/kelondro/index/RowSet.java
+++ b/source/de/anomic/kelondro/index/RowSet.java
@@ -169,12 +169,18 @@ public class RowSet extends RowCollection implements ObjectIndex, Iterable<Row.E
}
private synchronized Row.Entry remove(final byte[] a, final int start, final int length) {
- final int index = find(a, start, length);
- if (index < 0) return null;
- final Row.Entry entry = super.get(index, true);
- super.removeRow(index, true); // keep order of collection!
- int findagainindex = 0;
- assert (findagainindex = find(a, start, length)) < 0 : "remove: chunk found again at index position (after remove) " + findagainindex + ", index(before) = " + index + ", inset=" + NaturalOrder.arrayList(super.chunkcache, super.rowdef.objectsize * findagainindex, length) + ", searchkey=" + NaturalOrder.arrayList(a, start, length); // check if the remove worked
+ int index;
+ Row.Entry entry = null;
+ int s = this.size();
+ while ((index = find(a, start, length)) >= 0) {
+ entry = super.get(index, true);
+ super.removeRow(index, true); // keep order of collection!
+ // in case that the RowSet is not uniq, we must search again to delete all entries
+ // the following check will ensure that the process terminates
+ assert (this.size() < s);
+ if (this.size() >= s) return entry;
+ //assert (findagainindex = find(a, start, length)) < 0 : "remove: chunk found again at index position (after remove) " + findagainindex + ", index(before) = " + index + ", inset=" + NaturalOrder.arrayList(super.chunkcache, super.rowdef.objectsize * findagainindex, length) + ", searchkey=" + NaturalOrder.arrayList(a, start, length); // check if the remove worked
+ }
return entry;
}