Skip to main content

Adjacency

Struct Adjacency 

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

A relationship’s parent to children map.

Implementations§

Source§

impl Adjacency

Source

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

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

Two passes over the slice, one to count each parent’s children and one to place them, which is a counting sort. The children arrive in row order, so each list comes out ascending.

§Errors

If a parent rid is not NO_PARENT and is not below parents, for the reason crate::Link::build refuses the same thing.

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 edges(&self) -> u64

Children that point at a parent.

Source

pub fn bytes(&self) -> usize

Bytes the body costs, not counting the header.

Source

pub fn children_of(&self, parent: Rid, out: &mut Vec<Rid>) -> Result<()>

The child rows that point at parent, ascending, appended to out.

§Errors

If parent is past the end, or the packed rows are shorter than the lists say.

Source

pub fn reached(&self, held: &Rids) -> u64

How many children the parents of held have between them, without reading a child row.

Two selects a member, for a caller deciding whether Self::push is worth its gathers.

Source

pub fn push(&self, held: &Rids) -> Result<Rids>

The child rows that point into held, which is a set over the parent table.

The lists of the members, set as bits of one bitmap over the children, which the set then settles into whichever form its size calls for. A bit a child costs no comparison, where sorting the lists together cost a log a child, and the result is the exact set a forward push of held through the link would give.

§Errors

If held is not a set over the parent table.

Source

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

Appends the header and the body.

§Errors

If the width does not fit the byte the layout gives it, which no width a u64 takes can.

Source

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

Reads an adjacency from exactly the bytes Adjacency::write produced.

§Errors

If the payload is shorter than its header, names a layout this build does not know, or holds a body that is not the size its header implies.

Source

pub fn read_from(payload: Vec<u8>, at: usize) -> Result<Self>

Adjacency::read of the bytes of payload from at on, keeping payload for the child rows rather than copying them out of it. See Tail for why.

§Errors

As Adjacency::read, or if at is past the end of payload.

Trait Implementations§

Source§

impl Clone for Adjacency

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 Adjacency

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.