pub struct FileSplitStore { /* private fields */ }Expand description
File-backed split store for persistent runs.
Persists assignment metadata, epoch state, and sampler runtime state.
The store always works against a private temporary copy of the source
snapshot. All reads and mutations accumulate in the temp file.
State is published to permanent storage only when
SamplerStateStore::save_sampler_state is called:
save_to == None→ publish temp tosave_path(may overwrite).save_to == Some(p)→ publish temp toponly;save_pathis left untouched.
This guarantees that the original source file is never modified and that no partial state leaks to the target before an explicit save.
Implementations§
Source§impl FileSplitStore
impl FileSplitStore
Sourcepub fn open<P: Into<PathBuf>>(
path: P,
ratios: SplitRatios,
seed: u64,
) -> Result<Self, SamplerError>
pub fn open<P: Into<PathBuf>>( path: P, ratios: SplitRatios, seed: u64, ) -> Result<Self, SamplerError>
Open (or create) a file-backed split store at path.
Sourcepub fn open_with_load_path<LP: Into<PathBuf>, SP: Into<PathBuf>>(
load_path: Option<LP>,
save_path: SP,
ratios: SplitRatios,
seed: u64,
) -> Result<Self, SamplerError>
pub fn open_with_load_path<LP: Into<PathBuf>, SP: Into<PathBuf>>( load_path: Option<LP>, save_path: SP, ratios: SplitRatios, seed: u64, ) -> Result<Self, SamplerError>
Open (or create) a file-backed split store at save_path, optionally
bootstrapping initial state from load_path.
Always stages through a private temporary file. The source used to seed the temp is chosen as follows:
load_pathif supplied and it exists.save_pathif it already exists.- Nothing — a fresh empty store is created in the temp.
All mutations accumulate in the temp. State is published to permanent
storage only when SamplerStateStore::save_sampler_state is called.
The original source file is never modified.
Trait Implementations§
Source§impl Debug for FileSplitStore
impl Debug for FileSplitStore
Source§impl EpochStateStore for FileSplitStore
impl EpochStateStore for FileSplitStore
Source§fn load_epoch_meta(
&self,
) -> Result<HashMap<SplitLabel, PersistedSplitMeta>, SamplerError>
fn load_epoch_meta( &self, ) -> Result<HashMap<SplitLabel, PersistedSplitMeta>, SamplerError>
Source§fn load_epoch_hashes(
&self,
label: SplitLabel,
) -> Result<Option<PersistedSplitHashes>, SamplerError>
fn load_epoch_hashes( &self, label: SplitLabel, ) -> Result<Option<PersistedSplitHashes>, SamplerError>
Source§fn save_epoch_meta(
&self,
meta: &HashMap<SplitLabel, PersistedSplitMeta>,
) -> Result<(), SamplerError>
fn save_epoch_meta( &self, meta: &HashMap<SplitLabel, PersistedSplitMeta>, ) -> Result<(), SamplerError>
Source§fn save_epoch_hashes(
&self,
label: SplitLabel,
hashes: &PersistedSplitHashes,
) -> Result<(), SamplerError>
fn save_epoch_hashes( &self, label: SplitLabel, hashes: &PersistedSplitHashes, ) -> Result<(), SamplerError>
Source§impl SamplerStateStore for FileSplitStore
impl SamplerStateStore for FileSplitStore
Source§fn save_sampler_state(
&self,
state: &PersistedSamplerState,
save_to: Option<&Path>,
) -> Result<(), SamplerError>
fn save_sampler_state( &self, state: &PersistedSamplerState, save_to: Option<&Path>, ) -> Result<(), SamplerError>
Persist state to the working temp store and publish to the destination.
save_to == None→ publish temp tosave_path(may overwrite).save_to == Some(p)→ publish temp toponly;save_pathis left untouched.pmust not already exist.
Source§fn load_sampler_state(
&self,
) -> Result<Option<PersistedSamplerState>, SamplerError>
fn load_sampler_state( &self, ) -> Result<Option<PersistedSamplerState>, SamplerError>
Source§impl SplitStore for FileSplitStore
impl SplitStore for FileSplitStore
Source§fn label_for(&self, id: &RecordId) -> Option<SplitLabel>
fn label_for(&self, id: &RecordId) -> Option<SplitLabel>
id if known/derivable.Source§fn upsert(&self, id: RecordId, label: SplitLabel) -> Result<(), SamplerError>
fn upsert(&self, id: RecordId, label: SplitLabel) -> Result<(), SamplerError>
id.Source§fn ratios(&self) -> SplitRatios
fn ratios(&self) -> SplitRatios
Source§fn ensure(&self, id: RecordId) -> Result<SplitLabel, SamplerError>
fn ensure(&self, id: RecordId) -> Result<SplitLabel, SamplerError>
id, creating/deriving one when needed.Auto Trait Implementations§
impl !Freeze for FileSplitStore
impl RefUnwindSafe for FileSplitStore
impl Send for FileSplitStore
impl Sync for FileSplitStore
impl Unpin for FileSplitStore
impl UnsafeUnpin for FileSplitStore
impl UnwindSafe for FileSplitStore
Blanket Implementations§
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> 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 more