barrel_compaction_filter (barrel_docdb v1.0.0)
View SourceRocksDB compaction filter for revision tree pruning
This module implements revision pruning during RocksDB compaction. Each database has its own compaction filter handler that:
1. Processes doc_entity keys during compaction 2. Decodes the revtree from entity columns 3. Prunes old revisions based on depth 4. Deletes body entries for pruned revisions 5. Returns updated entity with pruned revtree
The filter is configured on the default column family where document entities are stored. Body deletions are issued via normal write_batch and cleaned up by RocksDB in subsequent compaction cycles.
Summary
Functions
Get the current prune depth
Get filter statistics for debugging
Handle compaction filter batch requests from RocksDB Message format: {compaction_filter, BatchRef, Keys} where Keys is a list of {Level, Key, Value} tuples
Reset filter statistics
Set the prune depth
Start a compaction filter handler for a database Options: - db_name: The database name (required) - prune_depth: Max revisions to keep per branch (default: 1000)
Functions
-spec get_prune_depth(pid()) -> non_neg_integer().
Get the current prune depth
Get filter statistics for debugging
Handle compaction filter batch requests from RocksDB Message format: {compaction_filter, BatchRef, Keys} where Keys is a list of {Level, Key, Value} tuples
-spec reset_stats(pid()) -> ok.
Reset filter statistics
-spec set_prune_depth(pid(), non_neg_integer()) -> ok.
Set the prune depth
Start a compaction filter handler for a database Options: - db_name: The database name (required) - prune_depth: Max revisions to keep per branch (default: 1000)
Note: The db_ref is looked up from persistent_term at runtime since the filter handler must be started before RocksDB is opened (to pass the handler pid to the CF options).