Skip to content

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

bugfixes for internals of database organization

orbiterf21ede312ea5
diff --git a/source/de/anomic/kelondro/kelondroBase64Order.java b/source/de/anomic/kelondro/kelondroBase64Order.java
index 4224f261f..9a026e5c0 100644
--- a/source/de/anomic/kelondro/kelondroBase64Order.java
+++ b/source/de/anomic/kelondro/kelondroBase64Order.java
@@ -298,9 +298,9 @@ public class kelondroBase64Order extends kelondroAbstractOrder implements kelond
bc = b[boffset + i];
assert (bc >= 0) && (bc < 128) : "bc = " + bc + ", b = " + serverLog.arrayList(b, boffset, len);
acc = ahpla[ac];
- assert (acc >= 0) : "acc = " + acc + ", a = " + serverLog.arrayList(a, aoffset, len) + ", aoffset = " + aoffset + serverLog.table(a, aoffset);
+ assert (acc >= 0) : "acc = " + acc + ", a = " + serverLog.arrayList(a, aoffset, len) + ", aoffset = 0x" + Integer.toHexString(aoffset) + serverLog.table(a, 16, aoffset);
bcc = ahpla[bc];
- assert (bcc >= 0) : "bcc = " + bcc + ", b = " + serverLog.arrayList(b, boffset, len) + ", boffset = " + boffset + serverLog.table(b, boffset);
+ assert (bcc >= 0) : "bcc = " + bcc + ", b = " + serverLog.arrayList(b, boffset, len) + ", boffset = 0x" + Integer.toHexString(boffset) + serverLog.table(b, 16, boffset);
if (acc > bcc) return 1;
if (acc < bcc) return -1;
// else the bytes are equal and it may go on yet undecided
diff --git a/source/de/anomic/kelondro/kelondroBufferedIndex.java b/source/de/anomic/kelondro/kelondroBufferedIndex.java
index f87cd82ff..1f9838344 100644
--- a/source/de/anomic/kelondro/kelondroBufferedIndex.java
+++ b/source/de/anomic/kelondro/kelondroBufferedIndex.java
@@ -67,6 +67,7 @@ public class kelondroBufferedIndex implements kelondroIndex {
Map.Entry entry;
if (i.hasNext()) {
entry = (Map.Entry) i.next();
+ System.out.println("*** DEBUG: flushed " + ((kelondroRow.Entry) entry.getValue()).getColString(0, null));
index.put((kelondroRow.Entry) entry.getValue());
}
}
diff --git a/source/de/anomic/kelondro/kelondroBytesIntMap.java b/source/de/anomic/kelondro/kelondroBytesIntMap.java
index 5da8a1853..f0ada0105 100644
--- a/source/de/anomic/kelondro/kelondroBytesIntMap.java
+++ b/source/de/anomic/kelondro/kelondroBytesIntMap.java
@@ -81,6 +81,7 @@ public class kelondroBytesIntMap {
public synchronized int removeonei() throws IOException {
if (ki.size() == 0) return -1;
kelondroRow.Entry indexentry = ki.removeOne();
+ assert (indexentry != null);
if (indexentry == null) return -1;
return (int) indexentry.getColLong(1);
}
diff --git a/source/de/anomic/kelondro/kelondroFlexTable.java b/source/de/anomic/kelondro/kelondroFlexTable.java
index 35fde208d..3f2b4403a 100644
--- a/source/de/anomic/kelondro/kelondroFlexTable.java
+++ b/source/de/anomic/kelondro/kelondroFlexTable.java
@@ -89,11 +89,14 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
kelondroRecords.Node node;
kelondroRow.Entry indexentry;
int i;
+ byte[] key;
while (content.hasNext()) {
node = (kelondroRecords.Node) content.next();
i = node.handle().hashCode();
+ key = node.getKey();
+ assert (key != null) : "DEBUG: empty key in initializeRamIndex"; // should not happen; if it does, it is an error of the condentNodes iterator
indexentry = ri.row().newEntry();
- indexentry.setCol(0, node.getKey());
+ indexentry.setCol(0, key);
indexentry.setCol(1, i);
ri.addUnique(indexentry);
if ((i % 10000) == 0) {
diff --git a/source/de/anomic/kelondro/kelondroNaturalOrder.java b/source/de/anomic/kelondro/kelondroNaturalOrder.java
index 4fcac9fc4..b5f67ca67 100644
--- a/source/de/anomic/kelondro/kelondroNaturalOrder.java
+++ b/source/de/anomic/kelondro/kelondroNaturalOrder.java
@@ -162,10 +162,10 @@ public class kelondroNaturalOrder extends kelondroAbstractOrder implements kelon
final int al = Math.min(alength, a.length - aoffset);
final int bl = Math.min(blength, b.length - boffset);
final int len = Math.min(al, bl);
- byte aa, bb;
+ int aa, bb;
while (i < len) {
- aa = a[i + aoffset];
- bb = b[i + boffset];
+ aa = 0xff & (int) a[i + aoffset];
+ bb = 0xff & (int) b[i + boffset];
if (aa > bb) return 1;
if (aa < bb) return -1;
// else the bytes are equal and it may go on yet undecided
diff --git a/source/de/anomic/kelondro/kelondroRecords.java b/source/de/anomic/kelondro/kelondroRecords.java
index c01f55a0d..145253020 100644
--- a/source/de/anomic/kelondro/kelondroRecords.java
+++ b/source/de/anomic/kelondro/kelondroRecords.java
@@ -1072,7 +1072,7 @@ public class kelondroRecords {
return markedDeleted;
}
- // handle seems to be corrent. store handle
+ // handle seems to be correct. store handle
markedDeleted.add(h);
// move to next handle
@@ -1147,9 +1147,10 @@ public class kelondroRecords {
Node nn = next00();
byte[] key = nn.getKey();
if ((key == null) ||
- ((key.length > 1) && ((key[0] == 0) && (key[1] == 0))) ||
- ((key.length > 3) && ((key[2] == 0) && (key[3] == 0)))) {
- // this is an deleted node; probably not commited with dispose
+ ((key.length == 1) && (key[0] == (byte) 0x80)) || // the NUL pointer ('lost' chain terminator)
+ ((key.length > 0) && (key[0] == 0)) // a 'lost' pointer within a deleted-chain
+ ) {
+ // this is a deleted node; probably not commited with dispose
if (fullyMarked) try {dispose(nn.handle);} catch (IOException e) {} // mark this now as deleted
continue;
}
diff --git a/source/de/anomic/kelondro/kelondroRowCollection.java b/source/de/anomic/kelondro/kelondroRowCollection.java
index b0fd20336..decbd68a2 100644
--- a/source/de/anomic/kelondro/kelondroRowCollection.java
+++ b/source/de/anomic/kelondro/kelondroRowCollection.java
@@ -83,8 +83,10 @@ public class kelondroRowCollection {
public kelondroRowCollection(kelondroRow rowdef, byte[] exportedCollectionRowinstance) {
this.rowdef = rowdef;
- kelondroRow.Entry exportedCollection = exportRow(exportedCollectionRowinstance.length - exportOverheadSize).newEntry(exportedCollectionRowinstance);
+ int chunkcachelength = exportedCollectionRowinstance.length - exportOverheadSize;
+ kelondroRow.Entry exportedCollection = exportRow(chunkcachelength).newEntry(exportedCollectionRowinstance);
this.chunkcount = (int) exportedCollection.getColLong(exp_chunkcount);
+ assert (this.chunkcount <= chunkcachelength / rowdef.objectsize) : "chunkcount = " + this.chunkcount + ", chunkcachelength = " + chunkcachelength + ", rowdef.objectsize = " + rowdef.objectsize;
this.lastTimeRead = (exportedCollection.getColLong(exp_last_read) + 10957) * day;
this.lastTimeWrote = (exportedCollection.getColLong(exp_last_wrote) + 10957) * day;
String sortOrderKey = exportedCollection.getColString(exp_order_type, null);
diff --git a/source/de/anomic/kelondro/kelondroRowSet.java b/source/de/anomic/kelondro/kelondroRowSet.java
index 6cab1a433..bd8e9c74a 100644
--- a/source/de/anomic/kelondro/kelondroRowSet.java
+++ b/source/de/anomic/kelondro/kelondroRowSet.java
@@ -166,6 +166,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
synchronized (chunkcache) {
resolveMarkedRemoved();
super.sort();
+ //if (super.rowdef.column(0).cellwidth() == 4) System.out.println("TABLE OF " + super.rowdef.toString() + "\n" + serverLog.table(super.chunkcache, super.rowdef.objectsize, 0)); // DEBUG
}
}
diff --git a/source/de/anomic/server/logging/serverLog.java b/source/de/anomic/server/logging/serverLog.java
index 035d77eca..e0e54eeff 100644
--- a/source/de/anomic/server/logging/serverLog.java
+++ b/source/de/anomic/server/logging/serverLog.java
@@ -219,6 +219,8 @@ public final class serverLog {
}
public static final String arrayList(byte[] b, int start, int length) {
+ if (b == null) return "NULL";
+ if (b.length == 0) return "[]";
StringBuffer sb = new StringBuffer(b.length * 4);
sb.append('[').append(Integer.toString((int) b[start])).append(',');
for (int i = 1; i < length; i++) sb.append(' ').append(Integer.toString((int) b[start + i])).append(',');
@@ -226,14 +228,17 @@ public final class serverLog {
return sb.toString();
}
- public static final String table(byte[] b, int marker) {
+ public static final String table(byte[] b, int linewidth, int marker) {
+ if (b == null) return "NULL";
+ if (b.length == 0) return "[]";
StringBuffer sb = new StringBuffer(b.length * 4);
for (int i = 0; i < b.length; i++) {
- if (i % 16 == 0)
+ if (i % linewidth == 0)
sb.append('\n').append("# ").append(Integer.toHexString(i));
else
sb.append(',');
- sb.append(' ').append(Integer.toString((int) b[i]));
+ sb.append(' ').append(Integer.toString(0xff & (int) b[i]));
+ if (i >= 65535) break;
}
sb.append('\n');
return sb.toString();