pub struct VenusDatabase { /* private fields */ }Expand description
The concrete database implementation.
This is the main entry point for incremental computation in Venus.
Create an instance with VenusDatabase::new() and use the helper
methods to interact with the incremental system.
Implementations§
Source§impl VenusDatabase
impl VenusDatabase
Sourcepub fn set_source(&self, path: PathBuf, text: String) -> SourceFile
pub fn set_source(&self, path: PathBuf, text: String) -> SourceFile
Create a new source file input.
Returns a handle that can be used with query functions.
Sourcepub fn update_source(&mut self, source: SourceFile, text: String)
pub fn update_source(&mut self, source: SourceFile, text: String)
Update an existing source file’s content.
This will invalidate all queries that depend on this source.
Sourcepub fn get_cells(&self, source: SourceFile) -> Vec<CellData>
pub fn get_cells(&self, source: SourceFile) -> Vec<CellData>
Parse cells from a source file.
Returns the list of cells extracted from the source. Returns an empty vector on parse errors.
Sourcepub fn get_cells_result(&self, source: SourceFile) -> QueryResult<Vec<CellData>>
pub fn get_cells_result(&self, source: SourceFile) -> QueryResult<Vec<CellData>>
Parse cells from a source file with error reporting.
Returns QueryResult::Ok with cells on success, or QueryResult::Err
with an error message on parse failure.
Sourcepub fn get_cell_names(&self, source: SourceFile) -> Vec<String>
pub fn get_cell_names(&self, source: SourceFile) -> Vec<String>
Get cell names from a source file.
Sourcepub fn get_execution_order(&self, source: SourceFile) -> Vec<usize>
pub fn get_execution_order(&self, source: SourceFile) -> Vec<usize>
Get the execution order for a notebook.
Returns cell indices in topological order. Returns an empty vector on graph errors.
Sourcepub fn get_execution_order_result(
&self,
source: SourceFile,
) -> QueryResult<Vec<usize>>
pub fn get_execution_order_result( &self, source: SourceFile, ) -> QueryResult<Vec<usize>>
Get the execution order for a notebook with error reporting.
Returns QueryResult::Ok with ordered indices on success, or
QueryResult::Err with an error message on graph errors (cycles,
missing dependencies, etc.).
Sourcepub fn get_invalidated(
&self,
source: SourceFile,
changed_idx: usize,
) -> Vec<usize>
pub fn get_invalidated( &self, source: SourceFile, changed_idx: usize, ) -> Vec<usize>
Get cells invalidated by a change.
Returns all cells that need to be re-executed when the given cell changes.
Sourcepub fn get_parallel_levels(&self, source: SourceFile) -> Vec<Vec<usize>>
pub fn get_parallel_levels(&self, source: SourceFile) -> Vec<Vec<usize>>
Get parallel execution levels.
Returns groups of cells that can be executed in parallel.
Sourcepub fn create_compiler_settings(
&self,
build_dir: PathBuf,
cache_dir: PathBuf,
universe_path: Option<PathBuf>,
use_cranelift: bool,
opt_level: u8,
) -> CompilerSettings
pub fn create_compiler_settings( &self, build_dir: PathBuf, cache_dir: PathBuf, universe_path: Option<PathBuf>, use_cranelift: bool, opt_level: u8, ) -> CompilerSettings
Create compiler settings input.
Sourcepub fn get_dependency_hash(&self, source: SourceFile) -> u64
pub fn get_dependency_hash(&self, source: SourceFile) -> u64
Get the dependency hash for a notebook.
This hash represents all external crate dependencies.
Sourcepub fn compile_cell(
&self,
source: SourceFile,
cell_idx: usize,
settings: CompilerSettings,
) -> CompilationStatus
pub fn compile_cell( &self, source: SourceFile, cell_idx: usize, settings: CompilerSettings, ) -> CompilationStatus
Compile a specific cell.
Returns the compilation status (success, cached, or failed).
Sourcepub fn compile_all(
&self,
source: SourceFile,
settings: CompilerSettings,
) -> Arc<Vec<CompilationStatus>>
pub fn compile_all( &self, source: SourceFile, settings: CompilerSettings, ) -> Arc<Vec<CompilationStatus>>
Compile all cells in execution order.
Returns compilation results for all cells.
Sourcepub fn create_cell_outputs(&self, cell_count: usize) -> CellOutputs
pub fn create_cell_outputs(&self, cell_count: usize) -> CellOutputs
Create a new cell outputs input with all cells pending.
Call this after parsing cells to initialize the outputs tracking.
Sourcepub fn set_cell_output(
&mut self,
outputs: CellOutputs,
cell_idx: usize,
status: ExecutionStatus,
)
pub fn set_cell_output( &mut self, outputs: CellOutputs, cell_idx: usize, status: ExecutionStatus, )
Update the execution status for a specific cell.
This will increment the version counter and invalidate any queries that depend on this cell’s output.
§Panics
In debug builds, panics if cell_idx is out of bounds. In release
builds, out-of-bounds indices are silently ignored (but version is
still incremented, which may cause unnecessary invalidations).
§Example
let outputs = db.create_cell_outputs(3);
db.set_cell_output(outputs, 0, ExecutionStatus::Running);Sourcepub fn get_cell_output(
&self,
outputs: CellOutputs,
cell_idx: usize,
) -> ExecutionStatus
pub fn get_cell_output( &self, outputs: CellOutputs, cell_idx: usize, ) -> ExecutionStatus
Get the execution status for a specific cell.
Returns ExecutionStatus::Pending if the cell index is out of bounds.
Sourcepub fn get_cell_output_data(
&self,
outputs: CellOutputs,
cell_idx: usize,
) -> Option<CellOutputData>
pub fn get_cell_output_data( &self, outputs: CellOutputs, cell_idx: usize, ) -> Option<CellOutputData>
Get the output data for a cell if it executed successfully.
Returns None if the cell is pending, running, failed, or out of bounds.
Sourcepub fn are_all_cells_executed(&self, outputs: CellOutputs) -> bool
pub fn are_all_cells_executed(&self, outputs: CellOutputs) -> bool
Check if all cells have finished executing.
Sourcepub fn mark_cell_running(&mut self, outputs: CellOutputs, cell_idx: usize)
pub fn mark_cell_running(&mut self, outputs: CellOutputs, cell_idx: usize)
Sourcepub fn mark_cell_failed(
&mut self,
outputs: CellOutputs,
cell_idx: usize,
error: String,
)
pub fn mark_cell_failed( &mut self, outputs: CellOutputs, cell_idx: usize, error: String, )
Mark a cell as failed with an error message.
§Panics
In debug builds, panics if cell_idx is out of bounds.
Sourcepub fn mark_cell_success(
&mut self,
outputs: CellOutputs,
cell_idx: usize,
output: CellOutputData,
)
pub fn mark_cell_success( &mut self, outputs: CellOutputs, cell_idx: usize, output: CellOutputData, )
Mark a cell as successfully executed with output data.
§Panics
In debug builds, panics if cell_idx is out of bounds.
Sourcepub fn create_cache_snapshot(
&self,
toolchain_version: String,
dependency_hash: u64,
cells: Vec<(String, u64, CompilationStatus)>,
) -> CacheSnapshot
pub fn create_cache_snapshot( &self, toolchain_version: String, dependency_hash: u64, cells: Vec<(String, u64, CompilationStatus)>, ) -> CacheSnapshot
Create a cache snapshot from current compilation state.
This captures all successfully compiled cells so they can be restored on the next startup without recompilation.
§Arguments
toolchain_version- Current rustc version stringdependency_hash- Hash of external dependenciescells- List of (name, source_hash, compilation_status)
§Example
let snapshot = db.create_cache_snapshot(
toolchain.version().to_string(),
db.get_dependency_hash(source),
compiled_cells,
);
CachePersistence::save(&cache_path, &snapshot)?;Sourcepub fn is_cell_cached(
&self,
snapshot: &CacheSnapshot,
cell_name: &str,
current_source_hash: u64,
) -> bool
pub fn is_cell_cached( &self, snapshot: &CacheSnapshot, cell_name: &str, current_source_hash: u64, ) -> bool
Check if a cached cell can be reused.
Returns true if the cell exists in the cache with a matching
source hash and successful compilation status.
Sourcepub fn get_cached_dylib_path(
&self,
snapshot: &CacheSnapshot,
cell_name: &str,
) -> Option<PathBuf>
pub fn get_cached_dylib_path( &self, snapshot: &CacheSnapshot, cell_name: &str, ) -> Option<PathBuf>
Get the dylib path for a cached cell.
Returns None if the cell is not in cache or failed compilation.
Trait Implementations§
Source§impl Clone for VenusDatabase
impl Clone for VenusDatabase
Source§fn clone(&self) -> VenusDatabase
fn clone(&self) -> VenusDatabase
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Database for VenusDatabase
impl Database for VenusDatabase
Source§fn trigger_lru_eviction(&mut self)
fn trigger_lru_eviction(&mut self)
Source§fn synthetic_write(&mut self, durability: Durability)
fn synthetic_write(&mut self, durability: Durability)
durability has changed, triggering a new revision.
This is mostly useful for profiling scenarios. Read moreSource§fn trigger_cancellation(&mut self)
fn trigger_cancellation(&mut self)
Source§fn report_untracked_read(&self)
fn report_untracked_read(&self)
Source§fn ingredient_debug_name(
&self,
ingredient_index: IngredientIndex,
) -> Cow<'_, str>
fn ingredient_debug_name( &self, ingredient_index: IngredientIndex, ) -> Cow<'_, str>
Source§fn unwind_if_revision_cancelled(&self)
fn unwind_if_revision_cancelled(&self)
Source§impl Default for VenusDatabase
impl Default for VenusDatabase
Source§fn default() -> VenusDatabase
fn default() -> VenusDatabase
Auto Trait Implementations§
impl !Freeze for VenusDatabase
impl RefUnwindSafe for VenusDatabase
impl Send for VenusDatabase
impl !Sync for VenusDatabase
impl Unpin for VenusDatabase
impl !UnwindSafe for VenusDatabase
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.