30 lines
938 B
Rust
Raw Normal View History

//! Atom operator: scan a [`Table`] under an [`AtomPattern`] and return a
//! binding [`Relation`].
//!
//! An atom pattern specifies, for each table column, either a variable to bind
//! or a literal that the cell must equal. A variable appearing in more than one
//! column forces those cells to be equal (so `Edge(X, X)` keeps only
//! self-loops). The output relation has one column per distinct variable, in
//! first-occurrence order.
use crate::{relation::Relation, table::Table, value::Value};
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Term {
Var(String),
Lit(Value),
}
#[derive(Debug, Clone)]
pub struct AtomPattern {
pub columns: Vec<Term>,
}
#[must_use]
pub fn scan_atom(_table: &Table, _pattern: &AtomPattern) -> Relation {
todo!(
"scan rows, filter by repeated-variable equality and literal equality, \
project to one column per distinct variable in first-occurrence order"
)
}