pub trait WalFilter: Send + Sync {
// Required methods
fn name(&self) -> &CStr;
fn log_record_found(
&self,
log_number: u64,
log_file_name: &[u8],
batch: &WriteBatch,
replacement: &mut WriteBatch,
) -> WalRecordAction;
// Provided method
fn column_family_log_number_map(
&self,
_cf_log_numbers: &ColumnFamilyLogNumbers<'_>,
) { ... }
}Expand description
A hook into WAL replay.
Implementations are shared: Options can be cloned and used to open several
DBs, all of which point at the same filter, so the methods take &self and
the trait requires Send + Sync. Reach for a Mutex or an atomic if the
filter needs to accumulate state.
§Panics
These methods are called from C++ across an extern "C" boundary, where an
unwind is undefined behaviour. A panic that escapes any of them aborts the
process instead. Return WalRecordAction::Corrupted to report a bad
record.
Required Methods§
Sourcefn name(&self) -> &CStr
fn name(&self) -> &CStr
Identifies this filter in the LOG file and in the error text RocksDB produces when the filter reports corruption.
The pointer behind the returned CStr is handed to C++ as is, so it has
to stay valid for as long as the filter does. A field of self or a
c"..." literal both work.
Sourcefn log_record_found(
&self,
log_number: u64,
log_file_name: &[u8],
batch: &WriteBatch,
replacement: &mut WriteBatch,
) -> WalRecordAction
fn log_record_found( &self, log_number: u64, log_file_name: &[u8], batch: &WriteBatch, replacement: &mut WriteBatch, ) -> WalRecordAction
Called for each WAL record recovery reads.
batch is the record as written. replacement starts empty and is only
looked at if this returns WalRecordAction::Replace, in which case it
is replayed in place of batch and inherits the original’s sequence
number.
log_file_name is the path of the log being read, for logging only. It
is raw bytes because it is built from the DB path, which this crate
passes through without validating it as UTF-8.
Provided Methods§
Sourcefn column_family_log_number_map(
&self,
_cf_log_numbers: &ColumnFamilyLogNumbers<'_>,
)
fn column_family_log_number_map( &self, _cf_log_numbers: &ColumnFamilyLogNumbers<'_>, )
Called once before replay starts, with the flush position of every column family.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".