Skip to main content

Link

Struct Link 

Source
pub struct Link { /* private fields */ }
Expand description

A relationship’s child to parent map.

Implementations§

Source

pub fn build(parents_of: &[Rid], parents: u64) -> Result<Self>

Builds a link from one parent rid per child, with NO_PARENT for the unmatched.

The form is chosen here and not by the caller: monotone when every child has a parent and the rids are non-decreasing, packed otherwise. That decision is a pass over the slice the caller already produced, so it costs a comparison per child on top of a build that was already linear.

§Errors

If a parent rid is not NO_PARENT and is not below parents, which means the link and the key map it was built against disagree about how many rows the parent table has. That is a bug rather than a data condition, and a link built past the end of its parent resolves to a row that is not there, which is the one failure in this layer that is a wrong answer.

Source

pub fn form(&self) -> Form

Which form the build chose.

Source

pub fn children(&self) -> u64

Rows in the child table.

Source

pub fn parents(&self) -> u64

Rows in the parent table.

Source

pub fn linked(&self) -> u64

Children that found a parent.

Source

pub fn bytes(&self) -> usize

Bytes the body costs, not counting the header.

Source

pub fn forward(&self, child: Rid) -> Option<Rid>

The parent of a child row, or None if it has none or the child is past the end.

Source

pub fn forward_run(&self, first: Rid, out: &mut [Rid]) -> Result<()>

The parents of a run of consecutive children, with NO_PARENT for the ones that have none.

This is Link::forward over a range, and what it adds is the monotone form. Answering one child there is a select1, which is a search, and walking a run of them one search at a time is paying for random access on a read that is sequential. So the run is found once and then read off the bitmap in order: a one bit is a child of the current parent and a zero bit moves on to the next parent, which is a load per sixty four bits and a count of zeros per word.

§Errors

If the run goes past the last child.

Source

pub fn backward(&self, parent: Rid) -> Option<Range<Rid>>

The children of a parent row, as a half open range of child rids.

None for the packed form, which does not answer this direction, and for a parent past the end. An empty range is a parent with no children and is not the same answer.

Source

pub fn part_bounds(&self, part: usize) -> Option<Bounds>

The minimum and maximum parent rid over one part of the child table, for section 5.5.

None for a part past the end of the table; Some(None) for a part in which no child has a parent, which is a part a reduction skips.

Source

pub fn write(&self, out: &mut Vec<u8>) -> Result<()>

Appends the header and the body.

§Errors

If a length does not fit the width the layout gives it.

Source

pub fn read(bytes: &[u8]) -> Result<Self>

Reads a link from exactly the bytes Link::write produced.

§Errors

If the payload is shorter than its header, names a form or a layout this build does not know, or holds a body that is not the size its header implies. Every one of those is a section to drop rather than a query to fail, by section 3.1.

Trait Implementations§

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§

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.