Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening a database from exiting data does not work #111

Open
ypriverol opened this issue Jul 27, 2019 · 5 comments
Open

Opening a database from exiting data does not work #111

ypriverol opened this issue Jul 27, 2019 · 5 comments

Comments

@ypriverol
Copy link

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.

@hbs
Copy link
Contributor

hbs commented Jul 27, 2019

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

@ypriverol
Copy link
Author

ypriverol commented Jul 27, 2019

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.

@pcmind
Copy link
Contributor

pcmind commented Jul 28, 2019

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

@asdj07
Copy link

asdj07 commented May 13, 2020

I have the same problem, did you resolve it ?

@JanCantCode
Copy link

same problem, is it resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants