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>
impl<D: DBAccess + 'static> OwnedPrefixProber<D>
Sourcepub fn new(db: Arc<D>) -> Self
pub fn new(db: Arc<D>) -> Self
Creates an owned prober over the default column family, using read options tuned for prefix probes.
Sourcepub fn with_opts(db: Arc<D>, readopts: ReadOptions) -> Self
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.
Sourcepub fn new_cf(db: Arc<D>, cf_handle: &impl AsColumnFamilyRef) -> Self
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.
Sourcepub fn cf_with_opts(
db: Arc<D>,
cf_handle: &impl AsColumnFamilyRef,
readopts: ReadOptions,
) -> Self
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.