Class WalFilter
- Namespace
- RocksDbNet
- Assembly
- RocksDb.Net.dll
Inspects, rewrites or skips write-ahead log records as RocksDb replays them
while opening a database.
Maps to rocksdb_walfilter_t.
public abstract class WalFilter : RocksDbHandle, IDisposable
- Inheritance
-
WalFilter
- Implements
- Inherited Members
Remarks
Only used during recovery, so the filter runs on the thread calling Open(DbOptions, string) and never concurrently.
Lifetime: RocksDb stores a raw pointer to the filter in the options and never frees it, so unlike EventListener the wrapper keeps ownership. SetWalFilter(WalFilter) registers the filter with the options so it is disposed alongside them.
Constructors
WalFilter(string)
protected WalFilter(string name)
Parameters
namestring
Methods
DisposeHandle()
Releases the native handle. Called during disposal.
protected override void DisposeHandle()
Remarks
Protected rather than public: it destroys the native object without marking this instance disposed or clearing the handle, so calling it from outside and then disposing normally would free the same pointer twice. It was the most Dispose-looking member on the type. Callers want Dispose().
LogRecordFound(ulong, string, WriteBatch, WriteBatch, ref bool)
Called for each record RocksDb replays, and decides what happens to it.
protected abstract WalProcessingOption LogRecordFound(ulong logNumber, string logFileName, WriteBatch batch, WriteBatch replacementBatch, ref bool batchChanged)
Parameters
logNumberulongNumber of the log file the record came from.
logFileNamestringName of that log file.
batchWriteBatchThe record as written. Valid only for the duration of this call, and must not be disposed or retained.
replacementBatchWriteBatchWrite a replacement here and set
batchChangedtotrueto have RocksDb apply this instead ofbatch. Same lifetime rules.batchChangedboolSet to
truewhenreplacementBatchshould be applied in place of the original.
Returns
Remarks
Runs during Open(DbOptions, string) on the calling thread. An exception is reported through UnhandledException and treated as ContinueProcessing, which applies the record unchanged.
OnColumnFamilyLogNumberMap(IReadOnlyDictionary<uint, ulong>, IReadOnlyDictionary<string, uint>)
Called once before replay begins, with the log number RocksDb will recover each column family from, and the id of each column family by name.
protected virtual void OnColumnFamilyLogNumberMap(IReadOnlyDictionary<uint, ulong> logNumbersByColumnFamilyId, IReadOnlyDictionary<string, uint> columnFamilyIdsByName)
Parameters
logNumbersByColumnFamilyIdIReadOnlyDictionary<uint, ulong>The log number each column family is being recovered from, keyed by column family id.
columnFamilyIdsByNameIReadOnlyDictionary<string, uint>Column family ids, keyed by name.
Remarks
Override this when LogRecordFound(ulong, string, WriteBatch, WriteBatch, ref bool) needs to know which column families exist. The default does nothing.