use std::collections::HashSet;
use std::sync::Arc;
use crate::error::PageProblem;
use crate::row_address::RowAddress;
use crate::schema::TableDefinition;
use crate::store::{PageKind, PageStore, RowPage};
#[derive(Default)]
pub(crate) struct Met(HashSet<RowAddress>);
impl Met {
pub(crate) fn first(&mut self, address: RowAddress) -> bool {
self.0.insert(address)
}
}
#[derive(Clone, Copy)]
pub(crate) struct ExtensionPages<'db> {
store: &'db PageStore,
definition: &'db TableDefinition,
}
impl<'db> ExtensionPages<'db> {
pub(crate) fn new(store: &'db PageStore, definition: &'db TableDefinition) -> Self {
Self { store, definition }
}
pub(crate) fn page(&self, number: u32) -> Result<Arc<RowPage>, PageProblem> {
if !self.definition.extension_pages.allows(number) {
return Err(PageProblem::Unlisted);
}
self.store
.shared_rows(number, PageKind::Extension, self.definition.id)
}
}