use uqa_core::memory::BudgetedVec;
use crate::mvcc::VersionResult;
use crate::read_control::StorageReadControl;
use super::{run::RunCacheReader, run_set::RunSet, PrivateRecordSnapshot};
pub struct PrivateRecordReadScope {
_readers: BudgetedVec<RunCacheReader>,
}
impl PrivateRecordReadScope {
pub(super) fn new(runs: &RunSet, control: &StorageReadControl) -> VersionResult<Self> {
control.check()?;
let mut readers = BudgetedVec::new(control.memory());
for run in runs.newest_first() {
readers.push(run.cache_reader())?;
}
Ok(Self { _readers: readers })
}
}
impl PrivateRecordSnapshot {
pub fn read_scope(
&self,
control: &StorageReadControl,
) -> VersionResult<PrivateRecordReadScope> {
PrivateRecordReadScope::new(&self.runs, control)
}
}
#[cfg(test)]
mod tests;