Skip to main content

RocksDbRegistry

Struct RocksDbRegistry 

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

RocksDB-backed inverse dictionary: 16-byte StrHash key → raw UTF-8 value.

Implementations§

Source§

impl RocksDbRegistry

Source

pub fn open( path: impl AsRef<Path>, tuning: RocksDbTuning, ) -> Result<Self, StorageError>

Open (or create) a registry DB at path with tuning.

Source

pub fn register( &self, hash: StrHash, raw: impl AsRef<[u8]>, ) -> Result<(), StorageError>

Put hash → raw (overwrites on duplicate).

Source

pub fn lookup(&self, hash: StrHash) -> Result<Option<String>, StorageError>

Look up the raw UTF-8 string for hash.

Source

pub fn lookup_many( &self, hashes: &[StrHash], ) -> Result<Vec<Option<String>>, StorageError>

Bulk resolve, positional like Self::lookup.

The lookup strategy is gated process-wide by WARATAH_RESOLVE_MULTIGET (see resolve_multiget_env_enabled): off (default) walks sorted seeks (Self::lookup_many_seek); on uses batched point reads (Self::lookup_many_multiget). Both are positional and return identical results — rocksdb_lookup_many_seek_matches_get_and_multiget holds all three equal — differing only in I/O shape on a cold cache.

Source

pub fn lookup_many_seek( &self, hashes: &[StrHash], ) -> Result<Vec<Option<String>>, StorageError>

Sorted unique keys, then monotonic Seek over one iterator per slice.

Default resolve path (WARATAH_RESOLVE_MULTIGET off): the registry’s fixed readahead and streaming per-key I/O, on one iterator or — the process default — several key-disjoint slices of the sorted groups.

Execution is gated process-wide by WARATAH_REGISTRY_WALKS (see [registry_walks]): unset splits into min(8, pool width) slices, K ≥ 2 sets that count, and 0 / 1 keeps the legacy single walk. Each slice is one storage worker with its own iterator (see Self::lookup_many_seek_with_workers).

Source

pub fn lookup_many_multiget( &self, hashes: &[StrHash], ) -> Result<Vec<Option<String>>, StorageError>

Sorted unique keys, then one pinned batched MultiGet (WARATAH_RESOLVE_MULTIGET=1): point reads whose misses can be served independently instead of the walk’s serial span. Values are pinned in RocksDB until the batch drops, so the classic C API’s per-value malloc/copy/free is gone. Sorted batches pass sorted_input=true, skipping RocksDB’s internal copy-and-sort of the key array.

Parallelism follows [registry_walks]: the unset default (and any explicit WARATAH_REGISTRY_WALKS=K) splits the sorted hash groups into contiguous slices, each resolved by its own storage worker (see Self::lookup_many_multiget_with_workers). Sharing the knob with the seek walk keeps the gate A/B fair by construction: both arms run the same K against the same pool width.

Source

pub fn lookup_many_get( &self, hashes: &[StrHash], ) -> Result<Vec<Option<String>>, StorageError>

Point-Get loop (test oracle vs Seek / MultiGet).

Source

pub fn apply_puts( &self, entries: &[(StrHash, String)], ) -> Result<u64, StorageError>

Write entries in one WriteBatch. Empty entries is a no-op.

Source

pub fn write_sorted_sst_run( &self, path: &Path, entries: &[(StrHash, String)], ) -> Result<(), StorageError>

Write entries as one sorted SST run file at path (bulk-ingest input).

entries must be sorted ascending by StrHash with no duplicates — the SstFileWriter contract (a BTreeMap<StrHash, _> iteration order satisfies it). The file uses the registry’s own SST layout (32 KiB blocks, LZ4), so it needs no rewrite after ingest.

Source

pub fn ingest_sst_runs(&self, files: &[PathBuf]) -> Result<(), StorageError>

Bulk-ingest sorted SST run files (Self::write_sorted_sst_run output) into the registry CF. Empty files is a no-op.

Runs may overlap each other’s key ranges: a StrHash is a pure hash of its raw string, so the same hash in two runs always carries the same value and whichever run wins is equivalent. No memtable flush is required and none is performed.

Source

pub fn warm_block_cache( &self, fill_fraction: f64, ) -> Result<WarmBlockCacheStats, StorageError>

Warm the registry’s block cache: one sequential walk over entries, stopping once usage reaches fill_fraction of capacity.

See [warm_walk]; the walk is what matters, values are dropped. A fill_fraction of 0 (or below) disables the walk.

Source

pub fn recover_staged_sst_runs( &self, staging_dir: &Path, ) -> Result<(), StorageError>

Ingest finished offline-import SST runs and delete staging_dir.

run-*.sst files are ingested in name order. run-*.sst.partial is an in-progress chunk and is deleted without being ingested. A missing directory is a no-op. If the ingest fails, the finished runs stay on disk so the next open can try again.

Source

pub fn flush_memtables(&self) -> Result<(), StorageError>

Flush the registry column family to SST files.

Source

pub fn compact_range(&self)

Compact the full key range of the registry column family.

Source

pub fn estimate_num_keys(&self) -> Option<u64>

Approximate key count from RocksDB (rocksdb.estimate-num-keys on the registry CF).

Source

pub fn lsm_metrics(&self) -> LsmMetrics

RocksDB LSM size / compaction counters (registry CF, not default).

Source

pub fn block_cache_bytes(&self) -> Option<(u64, u64)>

Process-wide block cache bytes: (capacity, charged usage).

Trait Implementations§

Source§

impl Debug for RocksDbRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,