Skip to main content

OutputDir

Struct OutputDir 

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

A directory that holds, or is about to hold, the results of one sweep, locked against other writers.

The lock is the operating system’s advisory lock on the file LOCK_FILE, released when the value is dropped. The file stays in the directory, and the next writer locks it again. The lock is released when the process that holds it ends, even when the process is killed.

A writer creates afresh each file it replaces. It appends to runs.csv and series.csv, and cuts them, only after Self::open has checked that neither table is a symbolic link.

Implementations§

Source§

impl OutputDir

Source

pub fn check_free(path: &Path) -> Result<(), OutputError>

Checks that the directory at path holds no results, without creating it.

A symbolic link under the name of a file counts as that file, even a link that points nowhere.

§Errors

Returns OutputError::HoldsResults when the directory holds a file that a sweep or a search writes, including a staged table or the marker of staged tables.

Source

pub fn create(path: &Path) -> Result<Self, OutputError>

Creates the directory at path and its parents, or uses an existing directory that holds no results, and locks it.

§Errors

Returns OutputError::HoldsResults when the directory holds a file that a sweep or a search writes, OutputError::Locked when another writer holds its lock, and OutputError::Write when it cannot be created.

Source

pub fn holds_results(path: &Path) -> bool

Returns whether the directory at path holds a file that a sweep or a search writes.

Source

pub fn open(path: &Path) -> Result<Self, OutputError>

Locks the existing directory at path, finishing a table replacement that a process left behind.

§Errors

Returns OutputError::Locked when another writer holds the directory’s lock, OutputError::Link when runs.csv or series.csv is a symbolic link, and OutputError::Write when the replacement cannot be finished or discarded.

Source

pub fn check_unlocked(path: &Path) -> Result<(), OutputError>

Checks that no writer holds the lock of the directory at path, without taking it.

§Errors

Returns OutputError::Locked when another writer holds the lock.

Source

pub fn path(&self) -> &Path

Path of the directory.

Source

pub fn open_writer( &self, plan: &Arc<Plan>, params: &[ParamDescriptor], measure: &MeasurePlan, ) -> Result<OutputWriter<BufWriter<File>>, OutputError>

Creates runs.csv and series.csv, and returns a writer for the runs of plan.

params are the model’s parameters, and measure fixes the stat and reducer columns.

§Errors

Returns OutputError::Write when a file exists already or cannot be created, or its header cannot be written.

Source

pub fn append_writer( &self, plan: &Arc<Plan>, params: &[ParamDescriptor], ) -> Result<OutputWriter<BufWriter<File>>, OutputError>

Opens runs.csv and series.csv, whose headers are already written, and returns a writer that adds the runs of plan to them.

§Errors

Returns OutputError::Write when a file cannot be opened.

Source

pub fn replace_tables( &self, write_runs: impl FnOnce(&mut dyn Write) -> Result<()>, write_series: impl FnOnce(&mut dyn Write) -> Result<()>, ) -> Result<(), OutputError>

Replaces runs.csv and series.csv with the text that write_runs and write_series write.

Each table is written in full beside the original with a .staged suffix. A marker file then records that both tables are complete, both tables are renamed into place, and the marker is removed. A process that ends between the marker and its removal leaves the replacement for Self::open to finish.

§Errors

Returns OutputError::Write when a write, a rename or a removal fails. The originals stay in place until both new tables are complete.

Source

pub fn order_tables(&self) -> Result<(), OutputError>

Rewrites runs.csv and series.csv with their runs in order of their ids, leaving tables already in order alone.

§Errors

Returns OutputError::Table when a table cannot be read back, and OutputError::Write when the replacement fails.

Source

pub fn create_table(&self, file: &str) -> Result<BufWriter<File>, OutputError>

Creates the table file afresh, removing any existing file of that name, and returns a buffered writer over it.

§Errors

Returns OutputError::Write when the file cannot be removed or created.

Source

pub fn write_manifest(&self, manifest: &Manifest) -> Result<(), OutputError>

Writes manifest to manifest.json. An earlier manifest is replaced by a single rename, so a reader sees either the old or the new manifest whole.

§Errors

Returns OutputError::Manifest when the manifest cannot be serialized, and OutputError::Write when a write or the rename fails.

Source

pub fn write_summary(&self) -> Result<(), OutputError>

Rebuilds summary.csv from runs.csv.

§Errors

Returns OutputError::Read when runs.csv cannot be read, OutputError::Write when summary.csv cannot be written, and OutputError::Summary when runs.csv cannot be summarized.

Trait Implementations§

Source§

impl Debug for OutputDir

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
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, 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> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WasmNotSync for T
where T: Sync,