bugfixes for internals of database organization

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

@ -298,9 +298,9 @@ public class kelondroBase64Order extends kelondroAbstractOrder implements kelond
bc = b[boffset + i]; bc = b[boffset + i];
assert (bc >= 0) && (bc < 128) : "bc = " + bc + ", b = " + serverLog.arrayList(b, boffset, len); assert (bc >= 0) && (bc < 128) : "bc = " + bc + ", b = " + serverLog.arrayList(b, boffset, len);
acc = ahpla[ac]; 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]; 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;
if (acc < bcc) return -1; if (acc < bcc) return -1;
// else the bytes are equal and it may go on yet undecided // else the bytes are equal and it may go on yet undecided

@ -67,6 +67,7 @@ public class kelondroBufferedIndex implements kelondroIndex {
Map.Entry entry; Map.Entry entry;
if (i.hasNext()) { if (i.hasNext()) {
entry = (Map.Entry) i.next(); entry = (Map.Entry) i.next();
System.out.println("*** DEBUG: flushed " + ((kelondroRow.Entry) entry.getValue()).getColString(0, null));
index.put((kelondroRow.Entry) entry.getValue()); index.put((kelondroRow.Entry) entry.getValue());
} }
} }

@ -81,6 +81,7 @@ public class kelondroBytesIntMap {
public synchronized int removeonei() throws IOException { public synchronized int removeonei() throws IOException {
if (ki.size() == 0) return -1; if (ki.size() == 0) return -1;
kelondroRow.Entry indexentry = ki.removeOne(); kelondroRow.Entry indexentry = ki.removeOne();
assert (indexentry != null);
if (indexentry == null) return -1; if (indexentry == null) return -1;
return (int) indexentry.getColLong(1); return (int) indexentry.getColLong(1);
} }

@ -89,11 +89,14 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
kelondroRecords.Node node; kelondroRecords.Node node;
kelondroRow.Entry indexentry; kelondroRow.Entry indexentry;
int i; int i;
byte[] key;
while (content.hasNext()) { while (content.hasNext()) {
node = (kelondroRecords.Node) content.next(); node = (kelondroRecords.Node) content.next();
i = node.handle().hashCode(); 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 = ri.row().newEntry();
indexentry.setCol(0, node.getKey()); indexentry.setCol(0, key);
indexentry.setCol(1, i); indexentry.setCol(1, i);
ri.addUnique(indexentry); ri.addUnique(indexentry);
if ((i % 10000) == 0) { if ((i % 10000) == 0) {

@ -162,10 +162,10 @@ public class kelondroNaturalOrder extends kelondroAbstractOrder implements kelon
final int al = Math.min(alength, a.length - aoffset); final int al = Math.min(alength, a.length - aoffset);
final int bl = Math.min(blength, b.length - boffset); final int bl = Math.min(blength, b.length - boffset);
final int len = Math.min(al, bl); final int len = Math.min(al, bl);
byte aa, bb; int aa, bb;
while (i < len) { while (i < len) {
aa = a[i + aoffset]; aa = 0xff & (int) a[i + aoffset];
bb = b[i + boffset]; bb = 0xff & (int) b[i + boffset];
if (aa > bb) return 1; if (aa > bb) return 1;
if (aa < bb) return -1; if (aa < bb) return -1;
// else the bytes are equal and it may go on yet undecided // else the bytes are equal and it may go on yet undecided

@ -1072,7 +1072,7 @@ public class kelondroRecords {
return markedDeleted; return markedDeleted;
} }
// handle seems to be corrent. store handle // handle seems to be correct. store handle
markedDeleted.add(h); markedDeleted.add(h);
// move to next handle // move to next handle
@ -1147,9 +1147,10 @@ public class kelondroRecords {
Node nn = next00(); Node nn = next00();
byte[] key = nn.getKey(); byte[] key = nn.getKey();
if ((key == null) || if ((key == null) ||
((key.length > 1) && ((key[0] == 0) && (key[1] == 0))) || ((key.length == 1) && (key[0] == (byte) 0x80)) || // the NUL pointer ('lost' chain terminator)
((key.length > 3) && ((key[2] == 0) && (key[3] == 0)))) { ((key.length > 0) && (key[0] == 0)) // a 'lost' pointer within a deleted-chain
// this is an deleted node; probably not commited with dispose ) {
// this is a deleted node; probably not commited with dispose
if (fullyMarked) try {dispose(nn.handle);} catch (IOException e) {} // mark this now as deleted if (fullyMarked) try {dispose(nn.handle);} catch (IOException e) {} // mark this now as deleted
continue; continue;
} }

@ -83,8 +83,10 @@ public class kelondroRowCollection {
public kelondroRowCollection(kelondroRow rowdef, byte[] exportedCollectionRowinstance) { public kelondroRowCollection(kelondroRow rowdef, byte[] exportedCollectionRowinstance) {
this.rowdef = rowdef; 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); 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.lastTimeRead = (exportedCollection.getColLong(exp_last_read) + 10957) * day;
this.lastTimeWrote = (exportedCollection.getColLong(exp_last_wrote) + 10957) * day; this.lastTimeWrote = (exportedCollection.getColLong(exp_last_wrote) + 10957) * day;
String sortOrderKey = exportedCollection.getColString(exp_order_type, null); String sortOrderKey = exportedCollection.getColString(exp_order_type, null);

@ -166,6 +166,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
synchronized (chunkcache) { synchronized (chunkcache) {
resolveMarkedRemoved(); resolveMarkedRemoved();
super.sort(); 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
} }
} }

@ -219,6 +219,8 @@ public final class serverLog {
} }
public static final String arrayList(byte[] b, int start, int length) { 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); StringBuffer sb = new StringBuffer(b.length * 4);
sb.append('[').append(Integer.toString((int) b[start])).append(','); 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(','); 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(); 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); StringBuffer sb = new StringBuffer(b.length * 4);
for (int i = 0; i < b.length; i++) { for (int i = 0; i < b.length; i++) {
if (i % 16 == 0) if (i % linewidth == 0)
sb.append('\n').append("# ").append(Integer.toHexString(i)); sb.append('\n').append("# ").append(Integer.toHexString(i));
else else
sb.append(','); 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'); sb.append('\n');
return sb.toString(); return sb.toString();

Loading…
Cancel
Save