a fix for problems with remove situations in kelondroFlexSplitTable

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2831 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent a17c43779f
commit 2025e885d6

@ -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 {

@ -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 position
long 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));

Loading…
Cancel
Save