Re: [Wb-discuss] bad block number error

From:

Aubrey Jaffer

Subject:

Re: [Wb-discuss] bad block number error

Date:

Thu, 17 Dec 2009 15:02:05 -0500 (EST)

| Date: Mon, 14 Dec 2009 09:36:51 +0100
| From: Floris Ouwendijk <address@hidden>
|
| Here's an example:
| ...
| Note that if I change the initialization to Wnts.initWb(100, 100,
| 4096); the problem stays.
Thanks for the program. It turns out that adding a single record with
key {255.31} to an empty b-tree is enough to cause the problem.
It turns out that keys starting with 0xFF are not supported by WB:
<http://people.csail.mit.edu/jaffer/wb_2.html#SEC14>
We've reserved the set of strings starting with `0xff' as split keys
only; they cannot be used as real key values.
But the API functions did not check for it! I have rectified that.
The development version now runs your program, outputting an error
message for every key starting with 0xFF. And the database file it
produces is valid.
All you need to do in order to work with arbitrary binary keys is to
prepend one byte (not 0xFF) to all keys. Existing applications of WB
either do this or have ASCII keys; so the problem didn't surface.
Thanks for your bug report. The development version is updated:
http://groups.csail.mit.edu/mac/ftpdir/users/jaffer/wb.zip
Also, the CVS repository is updated:
https://savannah.gnu.org/cvs/?group=wb
I had to modify your program in order to run it here. Here is my
version:
import wb.*;
public class Stress {
public static void main(String[] args) {
wb.Ents.initWb(120, 100, 2048);
wb.Seg btreeSeg = wb.Segs.makeSeg("stress.wb", 2048);
wb.Han btree = wb.Han.hanMakeHan();
wb.Segs.btCreate(btreeSeg, wb.Wbdefs.indTyp, btree, 1);
System.err.print("Java 0 to 999999 little-endian keys\n");
for (long i = 0; i < 100000; i++)
wb.Handle.btPut(btree, idToKey(i), 8, new byte[2], 2);
}
public static byte[] idToKey(long id) {
byte[] v = new byte[8];
int i = 0;
while (i < 8) {
v[i++] = (byte)(id & 0xff);
id>>=8;
}
return v;
}
}