Skip to main content

OwnedPrefixProber

Struct OwnedPrefixProber 

Source
pub struct OwnedPrefixProber<D: DBAccess + 'static> { /* private fields */ }
Expand description

A PrefixProber that keeps the database open instead of borrowing it.

Use this to cache a prober beyond the scope that built it, for example one per worker thread. PrefixProber borrows the database, so it cannot be held in a thread local or in shared state.

Everything PrefixProber documents about staleness and pinning applies here, and matters more, because the point of an owned prober is to outlive the request that created it. Refresh or drop cached probers on a timer. An idle one goes on pinning the memtables and SST files it was built over, and nothing will reclaim them.

D is 'static because the wrapper owns the database rather than borrowing it. Every DBWithThreadMode satisfies that.

Implementations§

Source§

impl<D: DBAccess + 'static> OwnedPrefixProber<D>

Source

pub fn new(db: Arc<D>) -> Self

Creates an owned prober over the default column family, using read options tuned for prefix probes.

Source

pub fn with_opts(db: Arc<D>, readopts: ReadOptions) -> Self

Creates an owned prober over the default column family with the given read options.

The prober owns readopts so that any buffers it points at, such as iterate bounds, stay alive for as long as the iterator.

Source

pub fn new_cf(db: Arc<D>, cf_handle: &impl AsColumnFamilyRef) -> Self

Creates an owned prober over one column family, using read options tuned for prefix probes.

Source

pub fn cf_with_opts( db: Arc<D>, cf_handle: &impl AsColumnFamilyRef, readopts: ReadOptions, ) -> Self

Creates an owned prober over one column family with the given read options.

cf_handle is only read while the iterator is being created. RocksDB takes its own reference to the column family, so the handle itself does not have to outlive the prober. Dropping the column family while a prober over it is alive is still not supported: the prober keeps reading the state it was built over, which is no longer meaningful.

Source

pub fn exists(&mut self, prefix: &[u8]) -> Result<bool, Error>

Returns true if any key exists with the given prefix.

See PrefixProber::exists.

§Errors

Returns the RocksDB error if the seek failed.

Source

pub fn refresh(&mut self) -> Result<(), Error>

Moves the probe to the latest committed state of the database.

See PrefixProber::refresh.

§Errors

Returns the RocksDB error if the refresh failed.

Auto Trait Implementations§

§

impl<D> Freeze for OwnedPrefixProber<D>
where PrefixProber<'static, D>: Freeze, Arc<D>: Freeze,

§

impl<D> RefUnwindSafe for OwnedPrefixProber<D>
where PrefixProber<'static, D>: RefUnwindSafe, Arc<D>: RefUnwindSafe,

§

impl<D> Send for OwnedPrefixProber<D>
where PrefixProber<'static, D>: Send, Arc<D>: Send,

§

impl<D> Sync for OwnedPrefixProber<D>
where PrefixProber<'static, D>: Sync, Arc<D>: Sync,

§

impl<D> Unpin for OwnedPrefixProber<D>
where PrefixProber<'static, D>: Unpin, Arc<D>: Unpin,

§

impl<D> UnsafeUnpin for OwnedPrefixProber<D>
where PrefixProber<'static, D>: UnsafeUnpin, Arc<D>: UnsafeUnpin,

§

impl<D> UnwindSafe for OwnedPrefixProber<D>
where PrefixProber<'static, D>: UnwindSafe, Arc<D>: UnwindSafe,

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.