Skip to main content

Catalog

Struct Catalog 

Source
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

Source

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.

Source

pub fn names(&self) -> impl ExactSizeIterator<Item = &str>

The tables in the file, in the order they were written.

Source

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.

Source

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.

Source

pub fn len(&self) -> usize

How many tables the file holds.

Source

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.

Source

pub fn table(&self, name: &str) -> Result<Reader>

Opens one table by name, decoding its directory now.

§Errors

If there is no table by that name, or its directory is torn or points outside the file.

Trait Implementations§

Source§

impl Clone for Catalog

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Catalog

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.