Closed KAIYOHUGO closed 1 year ago
I can make PR if this idea is acceptable.
Thank you for the request! Do you have a specific use case where snappy compression doesn't cut it? The downside of introducing such a compressor is obviously losing compatibility, although I agree it has the potential of slightly more elegant code as well.
Thanks for your reply! My use case is weird. I want to read Minecraft Bedrock world format and it is base on leveldb with zlib compression.
Introducing such a compressor indeed losing compatibility between Google's implementation, but for user it is no different.
They only need to change CompressionType::CompressionNone
to something like compressor::NoneCompressor::new()
. It can also make config compression more easy. e.g. change compression level
By the way. Google's implementation add zstd now, maybe it is a good time to add zstd?
Thank you for explaining, and in fact I didn't know that Google has added zstd by now! In that case I will try my hand at building the foundations for this, and then adding different compression algorithms should become fairly simple.
I have made a basic implementation, maybe it is worth to take a look?
I change Options
to this. Options.compressor
is the index in Options.compressor_list
, and the index also represents the magic number of compression.
struct Options {
...
compressor: u8,
compressor_list: [Option<Box<dyn Compressor>>; 256]
}
In current version is hardcode in rusty_leveldb::CompressionType.
I propose a
Compressor
traitthen change
rusty_leveldb::Options
to thisthis should fit in here and here