deephacks / lmdbjni

LMDB for Java
Apache License 2.0
204 stars 28 forks source link

setMapSize not working #61

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hi,

I have the following code,

        Env env = new Env();            
        env.open(storage_path,Constants.MAPASYNC|Constants.WRITEMAP);
        long mapsize = 100*1024*1024*1024;  //size 100 Gb
        env.setMapSize(mapsize);
        EnvInfo envinfo = env.info();
        System.out.println("Map size = "+envinfo.getMapSize());

I get in the standard output,

Map size = 1048576

as soon as operations start, I get

org.fusesource.lmdbjni.LMDBException: MDB_MAP_FULL: Environment mapsize limit reached at org.fusesource.lmdbjni.Util.checkErrorCode(Util.java:44) at org.fusesource.lmdbjni.Transaction.commit(Transaction.java:82) at org.fusesource.lmdbjni.Database.put(Database.java:384) at org.fusesource.lmdbjni.Database.put(Database.java:374)

I verify that the data file is indeed 1048576. Any idea on how to overcome this?

krisskross commented 8 years ago

This is how Java works. You're using an int to multiply then cast to long. The latest lmdbjni have a method setMapSize(size, ByteUnit)

ghost commented 8 years ago

Oh well, thanks for pointing it out. Now it works :-). I am closing this now.