barrel_compaction_filter (barrel_docdb v1.1.1)

View Source

RocksDB 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

get_prune_depth(Pid)

-spec get_prune_depth(pid()) -> non_neg_integer().

Get the current prune depth

get_stats(Pid)

-spec get_stats(pid()) -> map().

Get filter statistics for debugging

handle_call(Request, From, State)

handle_cast(Request, State)

handle_info(Info, State)

Handle compaction filter batch requests from RocksDB Message format: {compaction_filter, BatchRef, Keys} where Keys is a list of {Level, Key, Value} tuples

init(Opts)

reset_stats(Pid)

-spec reset_stats(pid()) -> ok.

Reset filter statistics

set_prune_depth(Pid, Depth)

-spec set_prune_depth(pid(), non_neg_integer()) -> ok.

Set the prune depth

start_link(Opts)

-spec start_link(map()) -> {ok, pid()} | {error, term()}.

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).

terminate(Reason, State)