Skip to main content

OpenAndCompactOptions

Struct OpenAndCompactOptions 

Source
pub struct OpenAndCompactOptions { /* private fields */ }
Expand description

Extra controls for open_and_compact_with_options.

These are RocksDB’s OpenAndCompactOptions from options.h.

Implementations§

Source§

impl OpenAndCompactOptions

Source

pub fn set_allow_resumption(&mut self, allow_resumption: bool)

Lets the compaction pick up where an earlier interrupted run left off.

With this on, the worker reads any progress left in the output directory and writes new progress there as each output file completes, so a retried job only redoes the file it was in the middle of. If the saved state cannot be used, it cleans the directory and starts fresh.

With this off, which is the default, the output directory must be empty before the call. Upstream is explicit that leftover files there can cause correctness errors.

Upstream marks this experimental and notes it does nothing when paranoid_file_checks is on.

Source

pub fn allow_resumption(&self) -> bool

Whether resumption is on. See Self::set_allow_resumption.

Source

pub fn set_canceled(&mut self, token: Arc<OpenAndCompactCancellationToken>)

Attaches a cancellation token so another thread can abort the compaction.

The C side stores the token as a borrowed std::atomic<bool>* inside the options struct (c.cc:1563), so the flag has to outlive both these options and the open_and_compact_with_options call that reads them. Holding an Arc clone enforces that at runtime and keeps OpenAndCompactOptions free of a lifetime parameter. Sharing the token is also the normal case, since something on another thread has to own a handle in order to cancel.

There is no way to detach a token once attached. The C API ignores a null argument rather than clearing the field (c.cc:1562).

Source

pub fn canceled(&self) -> Option<&Arc<OpenAndCompactCancellationToken>>

The cancellation token attached by Self::set_canceled, if there is one.

Handed back as the Arc so you can clone another handle out of it.

Trait Implementations§

Source§

impl Default for OpenAndCompactOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for OpenAndCompactOptions

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for OpenAndCompactOptions

Source§

impl Sync for OpenAndCompactOptions

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.