pub struct CompactionServiceOptionsOverride { /* private fields */ }Expand description
How the worker should open the column family it is about to compact.
A serialized compaction job carries the work but not the column family’s configuration, and RocksDB cannot serialize a comparator, a merge operator, or a prefix extractor. Whatever the primary DB was opened with has to be rebuilt here, or the worker produces output the primary cannot use.
from_options is the shortcut when the worker can
build the same Options the primary uses. create starts
from RocksDB defaults instead.
Every setter here replaces the previous value and none of them can be unset. The C API ignores a null argument rather than clearing the field (c.cc:1412 and the setters below it).
Implementations§
Source§impl CompactionServiceOptionsOverride
impl CompactionServiceOptionsOverride
Sourcepub fn create() -> Self
pub fn create() -> Self
Starts from RocksDB’s defaults: the default Env, the bytewise
comparator, a block-based table factory with default settings, no merge
operator, and no prefix extractor.
The table factory is set here rather than left alone on purpose. The C
struct leaves it null, and the worker copies every override field over the
column family’s own options unconditionally
(db/db_impl/db_impl_secondary.cc:1396), then dereferences the table
factory without a null check (db/column_family.cc:415). Handing a
freshly created override straight to open_and_compact would therefore
crash the worker, so this fills in the same default a plain Options
carries.
Sourcepub fn from_options(options: &Options) -> Self
pub fn from_options(options: &Options) -> Self
Copies the overridable settings out of options.
Thirteen fields are taken (c.cc:1381 to c.cc:1397): the env, file
checksum generator factory, comparator, merge operator, compaction
filter, compaction filter factory, prefix extractor, table factory, SST
partitioner factory, event listeners, statistics, info log, and table
properties collector factories. Anything else the worker needs has to go
through set_option.
Three of those are bare pointers rather than shared_ptrs, so this
keeps a handle on whatever options is holding them alive with, and the
override stays valid after options is dropped.
Sourcepub fn set_env(&mut self, env: &Env)
pub fn set_env(&mut self, env: &Env)
Sets the environment the worker reads and writes files through.
The C API stores a bare Env* (c.cc:1413), so this keeps a handle on
env for as long as the override lives.
Sourcepub fn set_comparator(&mut self, comparator: Arc<Comparator>)
pub fn set_comparator(&mut self, comparator: Arc<Comparator>)
Sets the key ordering, which must be the one the primary DB uses.
The C API stores a bare const Comparator* (c.cc:1421), so this takes
an Arc and holds a clone rather than borrowing. Sharing a comparator
is the normal case anyway, since the same one usually goes into the
worker’s own Options.
Sourcepub fn set_merge_operator<F: MergeFn, PF: MergeFn>(
&mut self,
name: impl CStrLike,
full_merge_fn: F,
partial_merge_fn: PF,
) -> Result<(), Error>
pub fn set_merge_operator<F: MergeFn, PF: MergeFn>( &mut self, name: impl CStrLike, full_merge_fn: F, partial_merge_fn: PF, ) -> Result<(), Error>
Sets the merge operator, which must be the one the primary DB uses.
Builds the operator here instead of taking a prepared one, because the
C API adopts the pointer into a std::shared_ptr<MergeOperator>
(c.cc:1429) and RocksDB frees it from then on. Handing the same pointer
to two of these would build two control blocks and free it twice, which
cannot happen when the only pointer is made on the spot.
The two callbacks mean what they do on
Options::set_merge_operator.
§Errors
Returns an error if name contains an interior NUL byte.
Sourcepub fn set_compaction_filter<F>(
&mut self,
name: impl CStrLike,
filter_fn: F,
) -> Result<(), Error>where
F: CompactionFilterFn + Send + 'static,
pub fn set_compaction_filter<F>(
&mut self,
name: impl CStrLike,
filter_fn: F,
) -> Result<(), Error>where
F: CompactionFilterFn + Send + 'static,
Drops or rewrites entries as the worker compacts them, the way
Options::set_compaction_filter
does on the primary.
The C API stores a bare const CompactionFilter* (c.cc:1438) instead of
adopting it, so the filter is built here and held for as long as the
override lives. Setting a second one destroys the first, after the C
struct has stopped pointing at it.
A filter set here wins over one from
set_compaction_filter_factory.
RocksDB only asks the factory when this field is null
(compaction_job.cc:1452).
§Errors
Returns an error if name contains an interior NUL byte.
Sourcepub fn set_compaction_filter_factory<F>(&mut self, factory: F)where
F: CompactionFilterFactory + 'static,
pub fn set_compaction_filter_factory<F>(&mut self, factory: F)where
F: CompactionFilterFactory + 'static,
Builds a fresh compaction filter for each compaction the worker runs.
Takes the factory by value because the C API adopts the pointer into a
std::shared_ptr<CompactionFilterFactory> (c.cc:1446), which makes
RocksDB responsible for freeing it.
Ignored while a filter set by
set_compaction_filter is in place.
Sourcepub fn set_prefix_extractor(&mut self, prefix_extractor: SliceTransform)
pub fn set_prefix_extractor(&mut self, prefix_extractor: SliceTransform)
Sets the prefix extractor, which must be the one the primary DB uses.
Takes the transform by value because the C API adopts the pointer into a
std::shared_ptr<const SliceTransform> (c.cc:1455), which makes RocksDB
responsible for freeing it.
Sourcepub fn set_block_based_table_factory(
&mut self,
table_options: &BlockBasedOptions,
)
pub fn set_block_based_table_factory( &mut self, table_options: &BlockBasedOptions, )
Writes output with a block based table factory built from
table_options.
The C API reads the options and builds a fresh factory from them
(c.cc:1464), so table_options is free to drop as soon as this returns.
A block cache set on it is carried into the factory by shared_ptr.
Sourcepub fn set_cuckoo_table_factory(&mut self, table_options: &CuckooTableOptions)
pub fn set_cuckoo_table_factory(&mut self, table_options: &CuckooTableOptions)
Writes output with a cuckoo table factory built from table_options.
Replaces any factory set by
set_block_based_table_factory,
since both write the same field. The C API builds a fresh factory from
the options (c.cc:1473), so table_options is free to drop as soon as
this returns.
Sourcepub fn set_sst_partitioner_factory(&mut self, factory: &SstPartitionerFactory)
pub fn set_sst_partitioner_factory(&mut self, factory: &SstPartitionerFactory)
Cuts output SST files on the boundaries this factory reports.
The C API copies the underlying shared_ptr (c.cc:1517), so the
caller’s handle is free to drop at any time.
Sourcepub fn set_file_checksum_gen_factory(
&mut self,
factory: &FileChecksumGenFactory,
)
pub fn set_file_checksum_gen_factory( &mut self, factory: &FileChecksumGenFactory, )
Records a whole file checksum for each SST the worker writes.
The C API copies the underlying shared_ptr (c.cc:1509), so the
caller’s handle is free to drop at any time.
Sourcepub fn set_statistics(&mut self, options: &Options)
pub fn set_statistics(&mut self, options: &Options)
Collects statistics for the compaction into the statistics object
options carries.
The C API reaches into an Options for its statistics and copies the
shared_ptr (c.cc:1485), so this takes an Options rather than a
statistics handle. Call
Options::enable_statistics on it
first, otherwise there is nothing to copy and this does nothing.
Upstream notes on CompactionServiceOptionsOverride that these counters
stay on the worker. Nothing is sent back to the primary DB.
Sourcepub fn set_info_log(&mut self, logger: InfoLogger)
pub fn set_info_log(&mut self, logger: InfoLogger)
Sends the worker’s log lines to logger instead of the default log
file.
Takes the logger by value, the same as
Options::set_info_logger, because a
callback logger owns the Rust closure it calls and the C API only copies
the C++ side of it (c.cc:1493).
Sourcepub fn set_option(
&mut self,
name: impl CStrLike,
value: impl CStrLike,
) -> Result<(), Error>
pub fn set_option( &mut self, name: impl CStrLike, value: impl CStrLike, ) -> Result<(), Error>
Sets one option by its name in the options string format.
The escape hatch for everything without a setter of its own, such as
compression or max_subcompactions. Names and values are the ones
RocksDB’s options string parser takes, for example "compression" and
"kZSTD". Both are copied into the override (c.cc:1501).
Upstream ignores a name it does not recognise rather than reporting it, so a typo here is silent.
§Errors
Returns an error if name or value contains an interior NUL byte.