-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Object Registry
The ObjectRegistry is a means by which alternative implementations of classes can be added and used by RocksDB programs. For example, an application may provide a custom Comparator class. By registering a factory for this class with the ObjectRegistry, an instance of a class can be created.
An ObjectRegistry
can be obtained via ObjectRegistry::Default
or ObjectRegistry::NewInstance
. An instance of a ConfigOptions
has an ObjectRegistry.
The ObjectRegistry is divided into libraries. A library provides a set of Factories that can be used to create instances of classes. Typically, libraries are divided into comparable functionality. For example, a "Test" library may register classes used for testing, whereas factories for certain features or plugins ("Cassandra", "HDFS") may be registered in their own libraries. Classes provided as part of the core RocksDB are typically registered in the Default library.
Factories may be registered with an library individually or via a Registrar function. A Registrar function typically registers factories individually. The code below shows a registrar function and the factories being registered:
static int RegisterTestObjects(ObjectLibrary& library,
const std::string& /*arg*/) {
size_t num_types;
library.Register<TableFactory>(
"MockTable",
[](const std::string& /*uri*/, std::unique_ptr<TableFactory>* guard,
std::string* /* errmsg */) {
guard->reset(new mock::MockTableFactory());
return guard->get();
});
return static_cast<int>(library.GetFactoryCount(&num_types));
}
config_options_.registry->AddLibrary("custom-tests", RegisterTestObjects, "");
This code snippet adds the "custom-tests" library to the registry. The RegisterTestFunctions
registers a factory to create a MockTable.
Factories are registered using a regular expression. For example, the registered factory:
lib->Register<EncryptionProvider>(
"CTR(://test)?",
[](const std::string& uri, std::unique_ptr<EncryptionProvider>* guard,
std::string* /*errmsg*/) {
...
});
Will match CTR://test
or CTR
. The "uri" argument to the factory will be the name that invoked this factory (e.g "CTR://test"
).
On success, a factory returns a pointer to the object. If the object is not static -- and can be deleted -- the guard should contain the same pointer. On error, errmsg should contain a message explaining the error.
Contents
- RocksDB Wiki
- Overview
- RocksDB FAQ
- Terminology
- Requirements
- Contributors' Guide
- Release Methodology
- RocksDB Users and Use Cases
- RocksDB Public Communication and Information Channels
-
Basic Operations
- Iterator
- Prefix seek
- SeekForPrev
- Tailing Iterator
- Compaction Filter
- Multi Column Family Iterator
- Read-Modify-Write (Merge) Operator
- Column Families
- Creating and Ingesting SST files
- Single Delete
- Low Priority Write
- Time to Live (TTL) Support
- Transactions
- Snapshot
- DeleteRange
- Atomic flush
- Read-only and Secondary instances
- Approximate Size
- User-defined Timestamp
- Wide Columns
- BlobDB
- Online Verification
- Options
- MemTable
- Journal
- Cache
- Write Buffer Manager
- Compaction
- SST File Formats
- IO
- Compression
- Full File Checksum and Checksum Handoff
- Background Error Handling
- Huge Page TLB Support
- Tiered Storage (Experimental)
- Logging and Monitoring
- Known Issues
- Troubleshooting Guide
- Tests
- Tools / Utilities
-
Implementation Details
- Delete Stale Files
- Partitioned Index/Filters
- WritePrepared-Transactions
- WriteUnprepared-Transactions
- How we keep track of live SST files
- How we index SST
- Merge Operator Implementation
- RocksDB Repairer
- Write Batch With Index
- Two Phase Commit
- Iterator's Implementation
- Simulation Cache
- [To Be Deprecated] Persistent Read Cache
- DeleteRange Implementation
- unordered_write
- Extending RocksDB
- RocksJava
- Lua
- Performance
- Projects Being Developed
- Misc