pub struct RocksDbRegistry { /* private fields */ }Expand description
RocksDB-backed inverse dictionary: 16-byte StrHash key → raw UTF-8 value.
Implementations§
Source§impl RocksDbRegistry
impl RocksDbRegistry
Sourcepub fn open(
path: impl AsRef<Path>,
tuning: RocksDbTuning,
) -> Result<Self, StorageError>
pub fn open( path: impl AsRef<Path>, tuning: RocksDbTuning, ) -> Result<Self, StorageError>
Open (or create) a registry DB at path with tuning.
Sourcepub fn register(
&self,
hash: StrHash,
raw: impl AsRef<[u8]>,
) -> Result<(), StorageError>
pub fn register( &self, hash: StrHash, raw: impl AsRef<[u8]>, ) -> Result<(), StorageError>
Put hash → raw (overwrites on duplicate).
Sourcepub fn lookup(&self, hash: StrHash) -> Result<Option<String>, StorageError>
pub fn lookup(&self, hash: StrHash) -> Result<Option<String>, StorageError>
Look up the raw UTF-8 string for hash.
Sourcepub fn lookup_many(
&self,
hashes: &[StrHash],
) -> Result<Vec<Option<String>>, StorageError>
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.
Sourcepub fn lookup_many_seek(
&self,
hashes: &[StrHash],
) -> Result<Vec<Option<String>>, StorageError>
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).
Sourcepub fn lookup_many_multiget(
&self,
hashes: &[StrHash],
) -> Result<Vec<Option<String>>, StorageError>
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.
Sourcepub fn lookup_many_get(
&self,
hashes: &[StrHash],
) -> Result<Vec<Option<String>>, StorageError>
pub fn lookup_many_get( &self, hashes: &[StrHash], ) -> Result<Vec<Option<String>>, StorageError>
Point-Get loop (test oracle vs Seek / MultiGet).
Sourcepub fn apply_puts(
&self,
entries: &[(StrHash, String)],
) -> Result<u64, StorageError>
pub fn apply_puts( &self, entries: &[(StrHash, String)], ) -> Result<u64, StorageError>
Write entries in one WriteBatch. Empty entries is a no-op.
Sourcepub fn write_sorted_sst_run(
&self,
path: &Path,
entries: &[(StrHash, String)],
) -> Result<(), StorageError>
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.
Sourcepub fn ingest_sst_runs(&self, files: &[PathBuf]) -> Result<(), StorageError>
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.
Sourcepub fn warm_block_cache(
&self,
fill_fraction: f64,
) -> Result<WarmBlockCacheStats, StorageError>
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.
Sourcepub fn recover_staged_sst_runs(
&self,
staging_dir: &Path,
) -> Result<(), StorageError>
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.
Sourcepub fn flush_memtables(&self) -> Result<(), StorageError>
pub fn flush_memtables(&self) -> Result<(), StorageError>
Flush the registry column family to SST files.
Sourcepub fn compact_range(&self)
pub fn compact_range(&self)
Compact the full key range of the registry column family.
Sourcepub fn estimate_num_keys(&self) -> Option<u64>
pub fn estimate_num_keys(&self) -> Option<u64>
Approximate key count from RocksDB (rocksdb.estimate-num-keys on the registry CF).
Sourcepub fn lsm_metrics(&self) -> LsmMetrics
pub fn lsm_metrics(&self) -> LsmMetrics
RocksDB LSM size / compaction counters (registry CF, not default).
Sourcepub fn block_cache_bytes(&self) -> Option<(u64, u64)>
pub fn block_cache_bytes(&self) -> Option<(u64, u64)>
Process-wide block cache bytes: (capacity, charged usage).