Skip to main content

FileHashCache

Enum FileHashCache 

Source
pub enum FileHashCache<'db> {
    Borrowed(&'db Connection),
}

Variants§

§

Borrowed(&'db Connection)

Implementations§

Source§

impl FileHashCache<'_>

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn get_cc_preprocess_memo( &self, memo_key: &str, ) -> Result<Option<CcPreprocessMemo>>

Source

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.

Source

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.

Source

pub fn prune_cc_preprocess_memos(&self) -> Result<(usize, usize)>

Source§

impl<'db> FileHashCache<'db>

Source

pub fn db(&self) -> &Connection

Source

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.

Source

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.

Source

pub fn put(&self, fingerprint: &FileFingerprint, hash: &str) -> Result<()>

Source

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.

Source

pub fn put_source_env_dep_use( &self, content_hash: &str, var: &str, scanner: u32, use_kind: i64, ) -> Result<()>

Source

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.

Source

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.

Source

pub fn put_input_prediction( &self, identity: &str, schema: u32, crate_name: Option<&str>, prediction_json: &str, ) -> Result<()>

Source

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.

Source

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.

Source

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<'_>

Source

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.

Source

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.

Source

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<'_>

Source

pub fn index_page_stats(&self) -> Result<IndexPageStats>

Source

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.

Source

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

compact_index for explicit repair: anything short of a compaction that was needed is an error the user can read.

Auto Trait Implementations§

§

impl<'db> !RefUnwindSafe for FileHashCache<'db>

§

impl<'db> !Send for FileHashCache<'db>

§

impl<'db> !Sync for FileHashCache<'db>

§

impl<'db> !UnwindSafe for FileHashCache<'db>

§

impl<'db> Freeze for FileHashCache<'db>

§

impl<'db> Unpin for FileHashCache<'db>

§

impl<'db> UnsafeUnpin for FileHashCache<'db>

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more