pub struct ExperimentStore { /* private fields */ }Expand description
In-memory store for experiment tracking data.
§Design
The store uses hash maps for O(1) lookups by ID, and stores metrics in a vector that can be filtered and sorted for time-series queries.
§Time-Series Optimization
The get_metrics_for_run function returns metrics ordered by step,
enabling efficient time-series visualization and analysis.
Implementations§
Source§impl ExperimentStore
impl ExperimentStore
Sourcepub fn experiment_count(&self) -> usize
pub fn experiment_count(&self) -> usize
Get the number of experiments in the store.
Sourcepub fn metric_count(&self) -> usize
pub fn metric_count(&self) -> usize
Get the number of metrics in the store.
Sourcepub fn add_experiment(&mut self, experiment: ExperimentRecord)
pub fn add_experiment(&mut self, experiment: ExperimentRecord)
Add an experiment to the store.
Sourcepub fn get_experiment(&self, experiment_id: &str) -> Option<&ExperimentRecord>
pub fn get_experiment(&self, experiment_id: &str) -> Option<&ExperimentRecord>
Get an experiment by ID.
Sourcepub fn get_runs_for_experiment(&self, experiment_id: &str) -> Vec<&RunRecord>
pub fn get_runs_for_experiment(&self, experiment_id: &str) -> Vec<&RunRecord>
Get all runs for an experiment.
Sourcepub fn add_metric(&mut self, metric: MetricRecord)
pub fn add_metric(&mut self, metric: MetricRecord)
Add a metric to the store.
Sourcepub fn get_metrics_for_run(&self, run_id: &str, key: &str) -> Vec<MetricRecord>
pub fn get_metrics_for_run(&self, run_id: &str, key: &str) -> Vec<MetricRecord>
Get metrics for a specific run and key, ordered by step.
This is the primary query function for time-series metric data.
§Arguments
run_id- The ID of the run to querykey- The metric key/name to filter by
§Returns
A vector of metrics matching the run_id and key, sorted by step
in ascending order.
§Example
use trueno_db::experiment::{ExperimentStore, MetricRecord};
let mut store = ExperimentStore::new();
// Log some training metrics
for step in 0..100 {
let loss = 1.0 / (step as f64 + 1.0);
store.add_metric(MetricRecord::new("run-001", "loss", step, loss));
}
// Query the loss curve
let loss_metrics = store.get_metrics_for_run("run-001", "loss");
assert_eq!(loss_metrics.len(), 100);Trait Implementations§
Source§impl Debug for ExperimentStore
impl Debug for ExperimentStore
Source§impl Default for ExperimentStore
impl Default for ExperimentStore
Source§fn default() -> ExperimentStore
fn default() -> ExperimentStore
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ExperimentStore
impl RefUnwindSafe for ExperimentStore
impl Send for ExperimentStore
impl Sync for ExperimentStore
impl Unpin for ExperimentStore
impl UnsafeUnpin for ExperimentStore
impl UnwindSafe for ExperimentStore
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
Mutably borrows from an owned value. Read more