dain / leveldb

Port of LevelDB to Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Opening a database from exiting data does not work

ypriverol opened this issue · comments

Hi:

I'm using levelDB for one of my projects and I found that when I copy one of my directories of levelDB and try to read it again it doesn't work:

levelDB.close();
FileUtils.deleteDirectory(new File(dbFile.getAbsolutePath()));
if(!dbFile.exists())
    dbFile.mkdirs();

ZipUtil.unpack(new File(filePath), new File(dbFile.getAbsolutePath()));
Options options = new Options();
                options.cacheSize(100 * 1048576)
                        .createIfMissing(true)
                        .writeBufferSize(4096)
                        .compressionType(CompressionType.SNAPPY);
                levelDB = Iq80DBFactory.factory.open(dbFile, options);
                String stats = levelDB.getProperty("leveldb.stats");

In the previous script the filePath is a zip file that contains the data from a previous levelDB instance. My question is How can I create a DB from the existing directory with data.

Did you copy the .sst files or also the MANIFEST and CURRENT ones?

I copy everything. The zip package contains also the LOCK file etc.

When I debug, I see 4 files:

0 = {File@2001} "/var/folders/hm/w90zk0x90sv25st_pm8xdw940000gq/T/temp6557883109835413908/properties-5124232907420.pldb/000003.log"
1 = {File@2002} "/var/folders/hm/w90zk0x90sv25st_pm8xdw940000gq/T/temp6557883109835413908/properties-5124232907420.pldb/LOCK"
2 = {File@2003} "/var/folders/hm/w90zk0x90sv25st_pm8xdw940000gq/T/temp6557883109835413908/properties-5124232907420.pldb/CURRENT"
3 = {File@2004} "/var/folders/hm/w90zk0x90sv25st_pm8xdw940000gq/T/temp6557883109835413908/properties-5124232907420.pldb/MANIFEST-000002"

BTW: I don't see @hbs .sst files.

If your DB is very small it is normal that you don't have sst file, all your data is in .log file. It should work as expected. Everything should be recovered from log file.
Did you close the DB before copying the files?
Note: this repo/implemtnation does not implement DB#getProperty(String) so it will always return null

I have the same problem, did you resolve it ?

same problem, is it resolved?