Skip to main content

JoinGraph

Struct JoinGraph 

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

A join query described precisely enough to bound provably.

See the module documentation for the theorem this implements and for where the degree statistics come from.

Implementations§

Source§

impl JoinGraph

Source

pub fn new(relations: Vec<JoinRelation>) -> Self

Build a graph over relations, with no predicates yet.

Source

pub fn with_edge( self, left: usize, right: usize, attribute: AttributeId, ) -> Self

Add an equality predicate between two relations on one attribute.

Out-of-range indices and self-edges are dropped: a misbuilt join graph must degrade the ceiling, never corrupt or panic it.

§Examples
use samkhya_core::degree::{JoinGraph, JoinRelation};

let g = JoinGraph::new(vec![JoinRelation::new(5), JoinRelation::new(7)])
    .with_edge(0, 1, 0)
    .with_edge(0, 9, 0);   // dropped: index 9 does not exist
assert_eq!(g.edges().len(), 1);
Source

pub fn relations(&self) -> &[JoinRelation]

The relations in this graph.

Source

pub fn edges(&self) -> &[JoinEdge]

The equality predicates in this graph.

Source

pub fn ceiling(&self) -> u64

A provable inclusive ceiling on the join’s output cardinality.

Never returns a value below the true cardinality of any database instance consistent with the supplied statistics, provided every AttributeDegree honours its soundness obligation.

The ceiling is the minimum of the Cartesian product and the spanning-tree degree bound evaluated from every possible root. Because every spanning tree yields a sound ceiling, the search over roots affects only tightness, never correctness.

§Examples
use samkhya_core::degree::{AttributeDegree, JoinGraph, JoinRelation};

// Three 3-row relations chained on two attributes, every row on the
// same key: the join really does degenerate to 27 rows, and the
// ceiling says so rather than pretending otherwise.
let rel = |n| JoinRelation::new(n);
let g = JoinGraph::new(vec![rel(3), rel(3), rel(3)])
    .with_edge(0, 1, 0)
    .with_edge(1, 2, 1);
assert_eq!(g.ceiling(), 27);

Trait Implementations§

Source§

impl Clone for JoinGraph

Source§

fn clone(&self) -> JoinGraph

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 JoinGraph

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for JoinGraph

Source§

fn default() -> JoinGraph

Returns the “default value” for a type. 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V