}
public void testBFile() throws IOException, DbException {
File tmpFile = File.createTempFile("bfile", ".tmp");
tmpFile.deleteOnExit();
BIndexFile bfile = new BIndexFile(tmpFile, false);
bfile.create(false);
List<byte[]> list = new ArrayList<byte[]>(REPEAT);
Random random = new Random(54552542345L);
StopWatch sw1 = new StopWatch("[BFileUniq] Index Construction of " + REPEAT);
for(int i = 0; i < REPEAT; i++) {
long v = random.nextLong();
byte[] b = Primitives.toBytes(v);
Value k = new Value(b);
bfile.addValue(k, b);
list.add(b);
}
System.err.println(sw1);
bfile.flush(true, true);
StopWatch sw2 = new StopWatch("[BFileUniq] Index Search of " + (REPEAT / 2));
for(int i = REPEAT - 1; i >= 0; i -= 2) {
byte[] b = list.get(i);
Assert.assertEquals("#" + i, new Value(b), bfile.getValue(new Value(b)));
}
System.err.println(sw2);
System.err.println("[BFileUniq] " + tmpFile.getAbsolutePath() + " - size: "
+ tmpFile.length());
bfile.drop();
}