dermesser / leveldb-rs

A reimplementation of LevelDB in Rust (no bindings).
Other
521 stars 59 forks source link

Fix the mcpe example #45

Closed theaddonn closed 6 months ago

theaddonn commented 6 months ago

The mcpe example is broken and doesn't work anymore. Some things have changed in the mcpe dbs and are not the same as they were. It would be lovely if this awesome example would be updated.

When running I get the error:

called `Result::unwrap()` on an `Err` value: Status { code: NotSupported, err: "invalid compression id `4`" }
dermesser commented 6 months ago

Unfortunately it's not me who has contributed this, and I don't know how to fix it. @KAIYOHUGO is the original author for all I can see - maybe they can take a look?

KAIYOHUGO commented 6 months ago

I think mojang's leveldb format change a lot since I wrote this example, and original mojang version of leveldb is disappear. From the copy in other repo, I think compression id 4 is leveldb_zlib_raw_compression. From my understand, leveldb_zlib_raw_compression is the same as leveldb_zlib_compression [^1]

I also need to mention that mojang's format is quite quirky, sometime it just don't work and I don't know why.

[^1]: They all base on ZlibCompressorBase

[`ZlibCompressorBase`'s implementation](https://github.com/reedacartwright/rbedrock/blob/fb32a899da4e15c1aaa0d6de2b459e914e183516/src/leveldb-mcpe/db/zlib_compressor.cc)
theaddonn commented 6 months ago

I sadly tried both leveldb_zlib_raw_compression and leveldb_zlib_compression for compression id 4, neither worked. Even though the original library disappeared it would still be nice to have this as an up to date example because it is a really practical and useful example. I am also very thankful that this library is well maintained!

KAIYOHUGO commented 6 months ago

@Adrian8115 I made some patch and more detail comment in the fork, can you test the problem still persist?

theaddonn commented 6 months ago

Thank you so much! It works great...

dermesser commented 6 months ago

Thank you so much @KAIYOHUGO for fixing it, and @Adrian8115 for bringing it to our attention :)

theaddonn commented 6 months ago

@KAIYOHUGO also thanks for the additional documentation!