Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
a fix for problems with remove situations in kelondroFlexSplitTable
orbiter2025e885d608
diff --git a/source/de/anomic/kelondro/kelondroFlexSplitTable.java b/source/de/anomic/kelondro/kelondroFlexSplitTable.javaindex d7faace93..aa2f16d5e 100644--- a/source/de/anomic/kelondro/kelondroFlexSplitTable.java+++ b/source/de/anomic/kelondro/kelondroFlexSplitTable.java@@ -120,15 +120,9 @@ public class kelondroFlexSplitTable implements kelondroIndex {}public synchronized kelondroRow.Entry get(byte[] key) throws IOException {- Iterator i = tables.values().iterator();- kelondroFlexTable table;- kelondroRow.Entry entry;- while (i.hasNext()) {- table = (kelondroFlexTable) i.next();- entry = table.get(key);- if (entry != null) return entry;- }- return null;+ Object[] keeper = keeperOf(key);+ if (keeper == null) return null;+ return (kelondroRow.Entry) keeper[1];}public synchronized kelondroRow.Entry put(kelondroRow.Entry row) throws IOException {@@ -136,7 +130,8 @@ public class kelondroFlexSplitTable implements kelondroIndex {}public synchronized kelondroRow.Entry put(kelondroRow.Entry row, Date entryDate) throws IOException {- kelondroRow.Entry r = remove(row.getColBytes(0));+ Object[] keeper = keeperOf(row.getColBytes(0));+ if (keeper != null) return ((kelondroFlexTable) keeper[0]).put(row, entryDate);String suffix = dateSuffix(entryDate);if (suffix == null) return null;kelondroFlexTable table = (kelondroFlexTable) tables.get(suffix);@@ -145,9 +140,20 @@ public class kelondroFlexSplitTable implements kelondroIndex {table = new kelondroFlexTable(path, tablename + "." + suffix, buffersize / (tables.size() + 1), -1, rowdef, objectOrder);tables.put(suffix, table);}-table.put(row);- return r;+ return null;+ }++ public synchronized Object[] keeperOf(byte[] key) throws IOException {+ Iterator i = tables.values().iterator();+ kelondroFlexTable table;+ kelondroRow.Entry entry;+ while (i.hasNext()) {+ table = (kelondroFlexTable) i.next();+ entry = table.get(key);+ if (entry != null) return new Object[]{table, entry};+ }+ return null;}public synchronized void addUnique(kelondroRow.Entry row) throws IOException {diff --git a/source/de/anomic/kelondro/kelondroRecords.java b/source/de/anomic/kelondro/kelondroRecords.javaindex 6afc714f5..d1c09e103 100644--- a/source/de/anomic/kelondro/kelondroRecords.java+++ b/source/de/anomic/kelondro/kelondroRecords.java@@ -979,6 +979,8 @@ public class kelondroRecords {// delete element with handle h// this element is then connected to the deleted-chain and can be// re-used change counter+ assert (h.index >= 0);+ assert (h.index != NUL);long sp = seekpos(h);if (sp >= entryFile.length()) {// a deletion of a node that cannot exist is wrong@@ -1279,7 +1281,7 @@ public class kelondroRecords {index = USAGE.USEDC - 1;} else {index = USAGE.FREEH.index;-+ //System.out.println("*DEBUG* ALLOCATED DELETED INDEX " + index);// check for valid seek positionlong seekp = seekpos(USAGE.FREEH);if (seekp > entryFile.length()) throw new kelondroException("new Handle: seek position " + seekp + "/" + USAGE.FREEH.index + " out of file size " + entryFile.length() + "/" + ((entryFile.length() - POS_NODES) / recordsize));