Skip to main content

Cache

Struct Cache 

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

Cache holds the store and the state of this run’s sync.

Implementations§

Source§

impl Cache

Source

pub fn record_edges(&self, source: &RepoPath, edges: Vec<RawEdge>)

record_edges holds the edges that one document declares until the commit writes them (CACHE-1_AC-11).

Source§

impl Cache

Source

pub fn set_hint(&self, paths: Vec<RepoPath>)

set_hint records the paths that a caller knows changed, so that the next sync reads the file metadata of only those paths.

Source

pub fn drop_hint(&self)

drop_hint forgets the paths that a caller said changed, so that the next sync walks the repository.

Source

pub fn note_missing(&self)

note_missing records that the run read a file that the walk lists and found it removed. In a run with a hint on a filled store, the hint left that removal out (CACHE-1_AC-53).

Source

pub fn missed(&self) -> bool

missed returns whether this run’s hint left out a removed file that the run read.

Source

pub fn hint(&self) -> Option<Vec<RepoPath>>

hint returns the paths that a caller said changed, or None when the caller gave none.

Source

pub fn tree_from_store( &self, root: &RepoRoot, config: &Config, changed: &[RepoPath], ) -> Result<Tree>

tree_from_store builds the tree that a run with a hint works on. It starts from the store’s files and directories. It drops what the store recorded at or under each hinted path, and lists those paths again as the walk lists them. It adds each directory above a hinted path that the walk lists, up to its root. It removes each directory above a hinted path that is no longer a directory. When no check has filled the store, it walks the repository instead.

Source§

impl Cache

Source

pub fn outside_to_read(&self) -> Vec<RepoPath>

outside_to_read returns the files outside the knowledge roots that this run must read for markers. A file is one of them when:

  • it is new
  • its stat changed
  • its modification time is so close to the last sync that a change might not show in the stat
Source

pub fn unread(&self, path: &RepoPath)

unread records a file that the scan could not read. The store keeps the file’s old row, so that the next run reads the file again, for example when its permissions change and its stat does not.

Source

pub fn record_markers(&self, path: &RepoPath, rows: Vec<MarkerRow>)

record_markers records the markers that a scan of path found. The commit writes them in place of the rows that the store holds for the file.

Source

pub fn stored_markers(&self, path: &RepoPath) -> Vec<MarkerRow>

stored_markers returns the markers of path that the store keeps, in line order.

Source

pub fn has_markers(&self, path: &RepoPath) -> bool

has_markers reports whether the store holds a row for any marker or fault in path.

Source§

impl Cache

Source

pub fn identities_changed(&self, rows: Vec<IdentityRow>) -> bool

identities_changed reports whether the current and former identities of the knowledge stores differ from the ones that the cache recorded. The commit writes the new rows (CACHE-1_AC-11).

Source

pub fn formats_changed( &self, hash: u64, fingerprint: impl FnOnce() -> Vec<(String, u64)>, ) -> Option<BTreeSet<String>>

formats_changed returns the registry entries that an edit of the formats file changed, or None when the file has the same hash as in the last run. When the hash differs, fingerprint computes one hash for each format and type of the current registry, and formats_changed compares them with the formats rows of the cache. The names whose hashes differ, and the names that were added or removed, make up the returned set. The commit writes the new hash and fingerprint (CACHE-1_AC-11).

Source

pub fn schemas_changed(&self, rows: Vec<SchemaRow>) -> BTreeSet<(usize, String)>

schemas_changed returns, as (knowledge store, key) pairs, the keys whose schema file differs from the cached one. A key’s schema file is the file that claims the key. It differs when the schema changed, was added or removed, or moved to another key. The commit writes the new rows (CACHE-1_AC-11).

Source

pub fn additional_changed(&self, rows: Vec<AdditionalRow>) -> BTreeSet<RepoPath>

additional_changed returns the additional files whose governing schema differs from the cached one: a glob started or stopped matching the file, or another schema now governs it. The commit writes the new rows (CACHE-1_AC-11).

Source

pub fn readers_of(&self, queries: &BTreeSet<String>) -> BTreeSet<RepoPath>

readers_of returns every reader of any of queries, as the cache recorded them. The queries table interns each query key and each reader’s path, and the deps table pairs their ids.

Source

pub fn history_queries(&self) -> BTreeSet<String>

history_queries returns the key of each query of the history that a stored check read, one for each commit that HEAD named (CACHE-1_AC-97).

Source

pub fn record_output(&self, path: &RepoPath, findings: Vec<Finding>)

record_output keeps the output of one check for the commit to write.

Source

pub fn record_deps(&self, path: &RepoPath, queries: &BTreeSet<Query>)

record_deps keeps the queries that one check made for the commit to write.

Source

pub fn record_unsettled<'a>(&self, paths: impl Iterator<Item = &'a RepoPath>)

record_unsettled adds to the queries of each of paths, which the run checked, the query that every run checks again, because each holds a text that the formatter left unsettled (CACHE-2_AC-9).

Source

pub fn record_citations(&self, source: &RepoPath, rows: Vec<CitationRow>)

record_citations keeps the citations that one document resolved for the commit to write.

Source

pub fn record_keys_of(&self, keys: &KeyIndex, checked: &BTreeSet<RepoPath>)

record_keys_of records the keys that each document in checked declares in this run, and the anchors that the engine keeps in the document. The commit writes them in place of the document’s rows in the cache.

Source

pub fn record_probe(&self, path: &RepoPath, on_disk: OnDisk)

record_probe records what a path outside the walk names on disk, nothing, a file, or a directory, so that the commit can write it. The next sync checks the path with stat again.

Source

pub fn record_assets(&self, rows: Vec<AssetRow>)

record_assets keeps the asset pairings of this run for the commit to write.

Source

pub fn assets_changed(&self, rows: &[AssetRow]) -> BTreeSet<RepoPath>

assets_changed returns the paths whose pairing differs from the cached one. Such a path is an asset or a sidecar that gained, lost, or changed its partner.

Source

pub fn probes_changed(&self, root: &RepoRoot) -> BTreeSet<RepoPath>

probes_changed returns the probed paths whose existence, or whose kind, a file or a directory, changed after the cache recorded it.

Source

pub fn stored_citations_of( &self, target: &RepoPath, excluding: &BTreeSet<RepoPath>, ) -> Vec<Citation>

stored_citations_of returns the citations of target that the cache holds, except those from removed files and from the sources in excluding. This run resolves the citations of those sources again.

Source

pub fn old_citation_targets(&self, source: &RepoPath) -> BTreeSet<RepoPath>

old_citation_targets returns the targets that source cited, as the cache recorded them.

Source

pub fn old_citations(&self, source: &RepoPath) -> BTreeSet<CitedFact>

old_citations returns what source cited, as the cache recorded it.

Source

pub fn stored_outputs(&self, except: &BTreeSet<RepoPath>) -> Vec<Finding>

stored_outputs returns the stored findings of every document except those in except, whose checks this run ran (CLI-4_AC-20).

Source§

impl Cache

Source

pub fn record_plans_of(&self, plans: &PlanIndex, checked: &BTreeSet<RepoPath>)

record_plans_of keeps the paths that each document in checked plans in this run. The commit writes them in place of the document’s rows in the store.

Source

pub fn old_plans_of(&self, path: &RepoPath) -> BTreeSet<Planned>

old_plans_of returns the paths that the document at path planned, as the store recorded them.

Source

pub fn stored_plans(&self, except: &BTreeSet<RepoPath>) -> PlanIndex

stored_plans returns the plans that the store records, except the plans of the documents in except and of the removed files.

Source§

impl Cache

Source

pub fn record_row(&self, path: &RepoPath, row: DocRow)

record_row keeps the row of a document that this run read. The commit writes the row when it differs from the store’s.

Source

pub fn old_row(&self, path: &RepoPath) -> Option<DocRow>

old_row returns the row that the store held for path before this run.

Source

pub fn stored_keys_for( &self, slugs: &BTreeSet<String>, except: &BTreeSet<RepoPath>, ) -> KeyIndex

stored_keys_for returns the keys that the store holds for the given slugs, from the documents that cite or capture them, and the anchors with those slugs that the engine keeps. It leaves out the rows of the documents that this run removed, and the rows of the documents in except, whose keys this run captured.

Source

pub fn old_keys_of(&self, path: &RepoPath) -> BTreeSet<(String, String, usize)>

old_keys_of returns the keys that the document at path declares, as the cache recorded them, each as (scope, slug, knowledge).

Source

pub fn old_anchors_of(&self, path: &RepoPath) -> BTreeSet<String>

old_anchors_of returns the slugs of the anchors that the engine keeps in the document at path, as the cache recorded them.

Source§

impl Cache

Source

pub fn open(root: &RepoRoot, mode: CacheMode) -> Cache

open opens the store under root, or opens it in memory for Off. When the store file does not open, the run uses a store in memory. When the store is of another version, format, or configuration, open replaces it with an empty one. Neither case prints a message.

Source

pub fn is_on(&self) -> bool

is_on returns whether the cache is on.

Source

pub fn is_fresh(&self) -> bool

is_fresh returns true when the store has no record of an earlier sync, because it is new, rebuilt, or in memory.

Source

pub fn begin_run(&self)

begin_run starts a run on this cache: it takes the time of the run’s start and sets the count of statements to zero, so that the counts of stats cover this run alone (CACHE-3_AC-4).

Source§

impl Cache

Source

pub fn sync(&self, tree: &Tree)

sync compares the walk with the store to decide which files this run must read (CACHE-1_AC-1, CACHE-1_AC-24). The sync treats a file as unchanged, and doesn’t read it, when two conditions hold. Its length and modification time equal those in the store. Its modification time is earlier than the last sync by at least RACY_MARGIN. The run reads any other file when a command needs it, and the hash of the file decides whether it changed. The walk is sorted by path, and the sync reads the rows of the store in the same order. So one pass yields the unchanged, changed, added, and removed files. The pass holds only the rows of the files that the run must read. sync also finds the directories that were added or removed.

Source

pub fn dirs_changed(&self) -> (Vec<RepoPath>, Vec<RepoPath>)

dirs_changed returns the directories that the walk lists and the store didn’t, and the directories that the store lists and the walk no longer does.

Source

pub fn must_read(&self, path: &RepoPath) -> bool

must_read says whether a run must read path before it can trust the hash in the store. The run must read the file when the file is new, when its stat differs from the stat in the store, when its modification time lies within RACY_MARGIN of the last sync, or when the walk doesn’t list it.

Source

pub fn observe(&self, path: &RepoPath, key: &FileKey) -> FileState

observe records that the run read a file. The hash in key decides whether the file changed, and the commit writes the row of the file.

Source

pub fn knowledge_of(&self, path: &RepoPath) -> Option<usize>

knowledge_of returns the knowledge root that a walked file lies under, if any.

Source

pub fn hash_of(&self, path: &RepoPath) -> Option<u64>

hash_of returns the hash of a walked file: the hash that this run read, the hash in the row of the store that the run holds, or, for a file that the run didn’t read, the hash that hash_of reads from the store.

Source

pub fn is_document(&self, path: &RepoPath) -> bool

is_document says whether the walk lists path as a document.

Source

pub fn is_schema(&self, path: &RepoPath) -> bool

is_schema says whether the walk lists path as a schema document.

Source

pub fn removed(&self) -> Vec<RepoPath>

removed returns the files that the walk no longer lists.

Source

pub fn is_new(&self, path: &RepoPath) -> bool

is_new says whether the store had no row for path before this run.

Source

pub fn pending_candidates(&self) -> Vec<(RepoPath, bool)>

pending_candidates returns the candidate files that the walk lists. The store doesn’t have their stat. Each is paired with a flag that says whether the store has no row for it yet. The documents that include or link such a file count as changed, although the run doesn’t read the file (CACHE-1_AC-26). For a candidate that the run read, such as an additional file, the hash decides instead whether the file changed.

Source

pub fn is_walked(&self, path: &RepoPath) -> bool

is_walked says whether the walk lists path.

Source

pub fn changed_set(&self) -> BTreeSet<RepoPath>

changed_set returns the files that this run read and found changed, as a set.

Source

pub fn changed(&self) -> Vec<RepoPath>

changed returns the files that this run read and found changed, in path order.

Source

pub fn stats(&self) -> SyncStats

stats returns the counts of the sync of this run, and of its work against the store.

Source

pub fn commit(&self)

commit writes the result of the run in one transaction: the rows of every walked file and of the directories, the deletion of the rows of the removed files, the rows, outputs, and markers that the run produced, and the sync time. A failure is silent, and the next run reads the files again (CACHE-1_AC-9).

Source§

impl Cache

Source

pub fn view(&self) -> Option<Box<dyn Fallback>>

view returns the store as a fallback for the model, or None when the store isn’t a file or can’t be opened.

Trait Implementations§

Source§

impl Debug for Cache

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Cache

§

impl !RefUnwindSafe for Cache

§

impl !Send for Cache

§

impl !Sync for Cache

§

impl !UnwindSafe for Cache

§

impl Forget for Cache

§

impl Move for Cache

§

impl Unpin for Cache

§

impl UnsafeUnpin for Cache

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'a, T> FromIn<'a, T> for T

Source§

fn from_in(t: T, _: &'a Allocator) -> T

Converts to this type from the input type within the given allocator.
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<'a, T, U> IntoIn<'a, U> for T
where U: FromIn<'a, T>,

Source§

fn into_in(self, allocator: &'a Allocator) -> U

Converts this type into the (usually inferred) input type within the given allocator.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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.