pub struct Catalog { /* private fields */ }Expand description
Every table a native file holds, without the directory of any of them.
This is what opening a database reads. It is the small level of the directory, so the cost is proportional to how many tables there are rather than to how much data they hold, and a session that touches two tables of eight decodes two table directories.
The file handle is shared with every reader this hands out. Eight tables in one file is one open file descriptor, not eight, which is the other thing one file buys over a file per table.
Implementations§
Source§impl Catalog
impl Catalog
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Reads the highest valid catalog slot and nothing under it.
§Errors
If the file has no valid committed catalog or a catalog pointer is out of bounds.
Sourcepub fn names(&self) -> impl ExactSizeIterator<Item = &str>
pub fn names(&self) -> impl ExactSizeIterator<Item = &str>
The tables in the file, in the order they were written.
Sourcepub fn rows(&self) -> impl ExactSizeIterator<Item = (&str, usize)>
pub fn rows(&self) -> impl ExactSizeIterator<Item = (&str, usize)>
The same tables with how many rows each of them holds.
The names alone answer which tables the file has, which is what a checkpoint needs to know. A load asks a second question: whether a table already in the file is really in the way of the one it wants to write. A table with no rows is not, because it has no pages the next generation would have to carry, so the count has to come out of the catalog beside the name.
Sourcepub fn views(&self) -> impl ExactSizeIterator<Item = &ViewEntry>
pub fn views(&self) -> impl ExactSizeIterator<Item = &ViewEntry>
The views in the file, in the order they were written.
Whole, unlike Catalog::names, which hands back names and makes the caller ask for a table
by one. A view is a few strings and a column list and it was all read at open, so there is
nothing left to go and fetch and no reason to make the caller ask twice.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the file holds no table at all, which is what Writer::empty writes and what a
database somebody dropped the last table out of comes back as.