pub struct SqliteStorage { /* private fields */ }Expand description
SQLite-backed storage: trials are persisted to a file so studies survive process restarts and can be resumed. Mirrors Optuna’s RDB storage pattern.
Each trial is stored as a JSON document keyed by (study_name, number),
which keeps the schema stable while faithfully round-tripping the
define-by-run parameter set and every intermediate report.
The connection is guarded by a Mutex, so the backend is Send + Sync and
usable under parallel execution. Several independent processes can also open
the same file (SQLite handles the file-level locking) for lightweight
multi-process coordination — a practical middle ground short of full
distributed execution.
Implementations§
Source§impl SqliteStorage
impl SqliteStorage
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self, StorageError>
pub fn open(path: impl AsRef<Path>) -> Result<Self, StorageError>
Open (creating if absent) a study database at path.
Sourcepub fn open_in_memory() -> Result<Self, StorageError>
pub fn open_in_memory() -> Result<Self, StorageError>
Open an anonymous in-memory SQLite database (useful for tests).
Trait Implementations§
Source§impl Storage for SqliteStorage
impl Storage for SqliteStorage
Source§fn save_trial(
&self,
study_name: &str,
trial: &Trial,
) -> Result<(), StorageError>
fn save_trial( &self, study_name: &str, trial: &Trial, ) -> Result<(), StorageError>
Source§fn load_trials(&self, study_name: &str) -> Result<Vec<Trial>, StorageError>
fn load_trials(&self, study_name: &str) -> Result<Vec<Trial>, StorageError>
Source§fn save_study_metadata(&self, meta: &StudyMetadata) -> Result<(), StorageError>
fn save_study_metadata(&self, meta: &StudyMetadata) -> Result<(), StorageError>
Source§fn load_study_metadata(
&self,
study_name: &str,
) -> Result<Option<StudyMetadata>, StorageError>
fn load_study_metadata( &self, study_name: &str, ) -> Result<Option<StudyMetadata>, StorageError>
None if the study is unknown.