-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Add support for compressor plugins #6717
base: main
Are you sure you want to change the base?
Conversation
@lucagiac81 This is very interesting. I am wondering if this is technically limited to just "Compression? It looks like I could implement a Compressor with the compress/decompress methods that would actually do encryption/decryption instead. Perhaps there is scope to generalise your approach a little further? |
@adamretter That's a great point. In general, this should work with any reversible data transformation. For encryption specifically, RocksDB already supports pluggable providers, but there could be other uses. |
8490c58
to
4872a8f
Compare
25e9471
to
51d169d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, I like this change but need to give this review some more thought in the details. Some general comments:
- Can we split out the "custom compression" changes into a new PR? That might simplify things slightly and make it easier to review
- I was wondering if it would be possible to change some of the logic/object construction slightly:
-> Rather than pass/store a CompressionType in the Table code, what if it the input argument was a Compressor? That would make fewer places that need to call into NewInstance and would make it easier if NewInstance was not static.
-> Does it make sense to move more stuff into the Compressor itself -- like the dictionary and the allocator -- rather than passing them in via the context objects? In other words, should those elements be part of the configuration for the Compressor or should they be specified on a per-method call basis?
I will try to go thru the specific code paths in more detail shortly.
include/rocksdb/advanced_options.h
Outdated
@@ -132,6 +133,9 @@ struct CompressionOptions { | |||
// Default: 1. | |||
uint32_t parallel_threads; | |||
|
|||
// Options for custom compressors | |||
std::unordered_map<std::string, std::string> custom_options; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, it would be better to use the Options/OptionTypeInfo system to define specific options for the extended types. I can work with you to get that set up.
51d169d
to
4a76539
Compare
@mrambacher Thanks for your feedback! I started by splitting the PR into multiple commits. I'll work on the remaining items. |
4a76539
to
870c8a8
Compare
615d8b7
to
9c10d24
Compare
9c10d24
to
2269649
Compare
2269649
to
5f0f15a
Compare
6e60a47
to
107130b
Compare
5d4737f
to
5fb11cf
Compare
2d126db
to
34bd404
Compare
34bd404
to
46a11fc
Compare
4437cb1
to
dde1fc3
Compare
a608471
to
925f379
Compare
925f379
to
a1c7090
Compare
f71338f
to
03af964
Compare
03af964
to
94fb688
Compare
94fb688
to
f316b22
Compare
f316b22
to
d061fae
Compare
d061fae
to
aa8ec63
Compare
31f5ff0
to
e4e690f
Compare
e4e690f
to
ce06833
Compare
3bedd21
to
3bd3653
Compare
3bd3653
to
14fa310
Compare
This is a follow-up to PR #7650, adding support for external compressor plugins.
The first commit in this PR will match PR #7650 until that is merged.
The Compressor and related classes are made part of the public API to allow development of plugins and to expose compressors in options.
Compressor plugins can be used to easily integrate new compression algorithms into RocksDB. They can also implement compression techniques tailored to specific types of data. For example, if the values in a database are of numeric type (e.g., arrays of integers) with particular distributions (e.g., limited range within each block), the values could be compressed using a lightweight compression algorithm implemented as a plugin (such as frame-of-reference or delta encoding).
Options for Compressors
New options are added to support plugin compressors.
For example, compression was previously configured by compression (of type CompressionType) and compression_opts (of type CompressionOptions). This PR adds a compressor option (pointer to Compressor) to specify a compressor object (which includes type and options).
This approach was followed for the following options:
The existing CompressionType/CompressionOptions options are preserved for backward compatibility.
If the user doesn't specify compressors (leaving them null), the CompressionType/CompressionOptions options are used as before. Otherwise, compressors override the existing options.
A new constant kPluginCompression is defined in CompressionType for plugin compressors. The SST properties block stores information about the specific compressor in the compression_name field. This is used to instantiate a suitable compressor when opening the SST.
Option String Examples
Built-in compressor (existing options)
compression=kZSTD;compression_opts={level=1}
Built-in compressor (new options)
compressor={id=ZSTD;level=1}
Plugin compressor (new options)
compressor={id=my_compressor;my_option1=value1;my_option2=value2}
Options Object Example
Built-in compressor (existing options)
Built-in compressor (new options)
Plugin compressor (new options)
db_bench
For db_bench, compression_type and individual compression options (such as compression_level) were left unchanged for backward compatibility.
compression_type is still used with plugin compressors to specify their name. Other compressor options can be passed using compressor_options.
Built-in compressor (existing options)
--compression_type=zstd --compression_level=1
Built-in compressor (new options)
--compression_type=zstd --compressor_options="level=1"
Plugin compressor (new options)
--compression_type=my_compressor --compressor_options="my_option1=value1;my_option2=value2"
Limitations/Future Work
Compressor plugins are currently not supported for
These limitations will be addressed by future PRs.