I've been having some trouble with BTrees on java6 and was wondering if anyone else was having similar issues. Looking through the mailing lists, it looks like java 7 is preferred, but I don't see where that's marked as a hard requirement. It looks like the bug has been fixed in java 7:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4938372. The problem also seems to go away if I turn off transactions. Posting to the mailing lists first in case this is really just user error or an incompatibility rather than a bug in mapDB.
Oracle jdk 1.6.0_31 running on Win7.
Test code:
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import org.mapdb.BTreeMap;
import org.mapdb.DB;
import org.mapdb.DBMaker;
public class Test
{
public static void main(String[] args) throws IOException {
URLConnection conn = new URL("
http://www.mapdb.org").openConnection();
DataInputStream is = new DataInputStream(conn.getInputStream());
int avail = is.available();
byte[] bytes = new byte[avail];
String data = null;
try {
is.readFully(bytes);
System.out.println(bytes.length);
data = new String(bytes);
}
finally {
is.close();
}
int tCnt = 0;
DB db = DBMaker.newFileDB(new File("C:\\data\\play\\test")).make();
BTreeMap<Object, Object> map = db.getTreeMap("foo");
for (int i = 0; i < 3000000; i++) {
map.put(tCnt, data);
if (tCnt % 10000 == 0) {
System.out.println(tCnt);
db.commit();
}
tCnt++;
}
db.commit();
db.close();
}
}
And the error I see:
java.lang.Error: Cleaner terminated abnormally
at sun.misc.Cleaner$1.run(Cleaner.java:130)
at java.security.AccessController.doPrivileged(Native Method)
at sun.misc.Cleaner.clean(Cleaner.java:127)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:124)
Caused by: java.io.IOException: The process cannot access the file because another process has locked a portion of the file
at sun.nio.ch.FileChannelImpl.unmap0(Native Method)
at sun.nio.ch.FileChannelImpl.access$100(FileChannelImpl.java:32)
at sun.nio.ch.FileChannelImpl$Unmapper.run(FileChannelImpl.java:667)
at sun.misc.Cleaner.clean(Cleaner.java:125)
... 1 more