pub enum FileHashCache<'db> {
Borrowed(&'db Connection),
}Variants§
Borrowed(&'db Connection)
Implementations§
Source§impl FileHashCache<'_>
impl FileHashCache<'_>
Sourcepub fn get_cc_mapped_hashes(
&self,
maps: &str,
contents: &[&str],
) -> Result<HashMap<String, String>>
pub fn get_cc_mapped_hashes( &self, maps: &str, contents: &[&str], ) -> Result<HashMap<String, String>>
Memoised mapped hashes for contents under the map set maps,
recorded under CC_MEMO_RULE or a later rule.
Sourcepub fn get_cc_asm_scans(
&self,
contents: &[&str],
) -> Result<HashMap<String, String>>
pub fn get_cc_asm_scans( &self, contents: &[&str], ) -> Result<HashMap<String, String>>
Memoised assembler scans for contents: the construct found, or an
empty string for a clean file. Only verdicts recorded under
CC_MEMO_RULE or a later rule count.
Sourcepub fn put_cc_asm_scans(&self, pairs: &[(String, String)]) -> Result<()>
pub fn put_cc_asm_scans(&self, pairs: &[(String, String)]) -> Result<()>
Record assembler scans from this invocation, in one transaction. A verdict an older rule recorded is replaced.
Sourcepub fn put_cc_mapped_hashes(
&self,
maps: &str,
pairs: &[(String, String)],
) -> Result<()>
pub fn put_cc_mapped_hashes( &self, maps: &str, pairs: &[(String, String)], ) -> Result<()>
Record mapped hashes computed this invocation, in one transaction. A mapped hash an older rule recorded is replaced.
pub fn get_cc_preprocess_memo( &self, memo_key: &str, ) -> Result<Option<CcPreprocessMemo>>
Sourcepub fn put_cc_preprocess_memo_inputs(
&self,
memo_key: &str,
preprocessed_hash: &str,
inputs: &[CcPreprocessMemoInput],
) -> Result<()>
pub fn put_cc_preprocess_memo_inputs( &self, memo_key: &str, preprocessed_hash: &str, inputs: &[CcPreprocessMemoInput], ) -> Result<()>
Record inputs as the read set behind preprocessed_hash.
Input rows are shared by every memo that read the same bytes under the same name. An input whose stamp had settled when it was observed gives the row its stamp, and the proof that lets a lookup trust it. One observed sooner never does: a second write in the same timestamp tick keeps the stamp and changes the bytes, so the row keeps the stamp it has, or starts with none.
Sourcepub fn touch_cc_preprocess_memo(&self, memo_key: &str) -> Result<usize>
pub fn touch_cc_preprocess_memo(&self, memo_key: &str) -> Result<usize>
Called after a successful validation and only when the read marked it due. The SQL guard also bounds updates by competing processes.
pub fn prune_cc_preprocess_memos(&self) -> Result<(usize, usize)>
Source§impl<'db> FileHashCache<'db>
impl<'db> FileHashCache<'db>
pub fn db(&self) -> &Connection
Sourcepub fn get(&self, fingerprint: &FileFingerprint) -> Result<Option<String>>
pub fn get(&self, fingerprint: &FileFingerprint) -> Result<Option<String>>
The memoised hash for fingerprint: a row whose whole stamp matches,
recorded under FILE_HASH_RULE or a later rule.
Sourcepub fn get_many(
&self,
fingerprints: &[&FileFingerprint],
) -> Result<HashMap<String, String>>
pub fn get_many( &self, fingerprints: &[&FileFingerprint], ) -> Result<HashMap<String, String>>
Memoised hashes for many files in one statement per chunk, keyed by
path. A row counts only when its whole stamp matches, so a file that
changed since it was recorded reads as absent, exactly as with get.
pub fn put(&self, fingerprint: &FileFingerprint, hash: &str) -> Result<()>
Sourcepub fn get_source_env_dep_use(
&self,
content_hash: &str,
var: &str,
scanner: u32,
) -> Result<Option<i64>>
pub fn get_source_env_dep_use( &self, content_hash: &str, var: &str, scanner: u32, ) -> Result<Option<i64>>
The stored classification of how the source with content_hash uses
var. scanner is the caller’s scanner version: a row recorded by any
other version reads as absent, so a scanner fix never reuses an answer
the old scanner gave for unchanged source. use_kind is opaque here.
pub fn put_source_env_dep_use( &self, content_hash: &str, var: &str, scanner: u32, use_kind: i64, ) -> Result<()>
Sourcepub fn has_entry_for_unit(&self, crate_name: &str, unit: &str) -> Result<bool>
pub fn has_entry_for_unit(&self, crate_name: &str, unit: &str) -> Result<bool>
Whether any entry, committed or not, was stored under crate_name
for unit, Cargo’s -C metadata hash, or with no unit recorded.
Every cache key folds the crate name and that hash in, so false
means no key this unit can produce is in the local store. A row with
no unit (stored by an older kache, or by a path that never learns
the unit) counts for every unit of its crate name. An empty unit
asks about the crate name alone.
Sourcepub fn get_input_prediction(
&self,
identity: &str,
) -> Result<Option<(u32, String)>>
pub fn get_input_prediction( &self, identity: &str, ) -> Result<Option<(u32, String)>>
Return the stored schema and payload for identity, or None when absent.
The caller validates the schema before interpreting the payload.
A read is a use: it refreshes the row’s last_used stamp, at most once
per INPUT_PREDICTION_TOUCH_INTERVAL_SECS so a build does not issue
one write per unit.
pub fn put_input_prediction( &self, identity: &str, schema: u32, crate_name: Option<&str>, prediction_json: &str, ) -> Result<()>
Sourcepub fn prune_input_predictions(&self) -> Result<usize>
pub fn prune_input_predictions(&self) -> Result<usize>
Delete predictions no build has read or recorded for
INPUT_PREDICTION_RETENTION_SECS. Run from the GC sweep and
doctor --repair. Freed pages go to the freelist; index compaction
returns them to disk.
Sourcepub fn prune_file_hashes(&self) -> Result<usize>
pub fn prune_file_hashes(&self) -> Result<usize>
Delete file hash rows not written for FILE_HASH_RETENTION_SECS.
Run from the GC sweep and doctor --repair, like
Self::prune_input_predictions. A lookup never refreshes a row, so
that the hit path stays read-only; the price is one re-hash a month
for a file read that whole time without changing.
Sourcepub fn rebuild_file_hashes_without_rowid(&self) -> Result<bool>
pub fn rebuild_file_hashes_without_rowid(&self) -> Result<bool>
Rebuild an older store’s file_hashes as a WITHOUT ROWID table,
which keeps each path once instead of in the table and again in its
primary key index: 27% smaller on a real 1.3-million-row table
(kunobi-ninja/kache#1206). Copying takes the write lock for about a
second per million rows, so it runs from the GC sweep after the prune,
never when a build opens the index. Returns whether it rebuilt. A
table without a rule column copies its rows at rule 0, which no
lookup serves.
Source§impl FileHashCache<'_>
impl FileHashCache<'_>
Sourcepub fn lookup_cached(&self, path: &Path) -> FileHashLookup
pub fn lookup_cached(&self, path: &Path) -> FileHashLookup
Cache lookup ONLY — reads the persistent hash cache, never computes a
blake3. Lets a caller holding a coarse lock (the daemon’s Mutex<Store>)
release it before the expensive file read and re-take it only for the
short record (#281). Mirrors FileHasher::hash’s fingerprint + min-size +
cache-get logic exactly, so the cache key is identical.
Sourcepub fn record_cached(&self, fingerprint: &FileFingerprint, hash: &str)
pub fn record_cached(&self, fingerprint: &FileFingerprint, hash: &str)
Record a freshly-computed hash for fingerprint (the miss arm of
Self::lookup_cached). Best-effort — a cache write failure is logged,
not propagated.
Sourcepub fn record_verified(&self, fingerprint: &FileFingerprint, hash: &str)
pub fn record_verified(&self, fingerprint: &FileFingerprint, hash: &str)
Record a hash the caller already knows for fingerprint — without
reading the file (kunobi-ninja/kache#540).
The caller must have established that hash for THAT fingerprint, not merely for that path: the row is only ever served back on an exact fingerprint match, so a fingerprint captured at the moment the content was known stays a true statement even if the file changes a moment later — the changed file simply misses and gets hashed. Re-stating the path here instead would pair the new file’s fingerprint with the old file’s hash.
Honors the same size floor as FileHasher::hash, which would not consult
the memo for a smaller file anyway.
Source§impl FileHashCache<'_>
impl FileHashCache<'_>
pub fn index_page_stats(&self) -> Result<IndexPageStats>
Sourcepub fn compact_index(&self) -> Result<IndexCompaction>
pub fn compact_index(&self) -> Result<IndexCompaction>
VACUUM the index when its freelist is large. Index reads continue
while it runs but writes wait, so callers pick a quiet moment; a
contended index reports Busy instead of failing.