Skip to main content

Store

Trait Store 

Source
pub trait Store {
    // Required methods
    fn scan(
        &self,
        relation: &str,
    ) -> Result<Box<dyn Iterator<Item = Vec<Value>> + '_>, Error>;
    fn scan_delta(
        &self,
        relation: &str,
    ) -> Result<Box<dyn Iterator<Item = Vec<Value>> + '_>, Error>;
    fn scan_next_delta(
        &self,
        relation: &str,
    ) -> Result<Box<dyn Iterator<Item = Vec<Value>> + '_>, Error>;
    fn scan_index(
        &self,
        relation: &str,
        col_idx: usize,
        key: &Value,
    ) -> Result<Box<dyn Iterator<Item = Vec<Value>> + '_>, Error>;
    fn scan_delta_index(
        &self,
        relation: &str,
        col_idx: usize,
        key: &Value,
    ) -> Result<Box<dyn Iterator<Item = Vec<Value>> + '_>, Error>;
    fn insert(
        &mut self,
        relation: &str,
        tuple: Vec<Value>,
    ) -> Result<bool, Error>;
    fn merge_deltas(&mut self);
    fn create_relation(&mut self, relation: &str);
    fn retract(
        &mut self,
        relation: &str,
        tuple: &[Value],
    ) -> Result<bool, Error>;
    fn clear(&mut self, relation: &str);
    fn relation_names(&self) -> Vec<String>;

    // Provided method
    fn coalesce_temporal(&mut self, _relation: &str) { ... }
}
Expand description

Abstract interface for relation storage (Edge Mode).

Tuples are currently stored as Vec<Value> where compound values (lists, structs, maps) appear as Value::Compound(...).

TODO: Support explicit table flattening. When a user annotates a type declaration, compound columns should be inlined into the tuple as length-prefixed sequences of scalar values. This flattening should only apply to explicitly requested levels of the type tree (no automatic recursive flattening). The Store would then see wider tuples of scalar values instead of Compound entries.

Required Methods§

Source

fn scan( &self, relation: &str, ) -> Result<Box<dyn Iterator<Item = Vec<Value>> + '_>, Error>

Returns an iterator over all tuples in the relation. Returns an error if the relation does not exist.

Source

fn scan_delta( &self, relation: &str, ) -> Result<Box<dyn Iterator<Item = Vec<Value>> + '_>, Error>

Returns an iterator over only the new tuples added in the last iteration.

Source

fn scan_next_delta( &self, relation: &str, ) -> Result<Box<dyn Iterator<Item = Vec<Value>> + '_>, Error>

Returns an iterator over tuples being collected for the next iteration.

Source

fn scan_index( &self, relation: &str, col_idx: usize, key: &Value, ) -> Result<Box<dyn Iterator<Item = Vec<Value>> + '_>, Error>

Returns an iterator over tuples in the relation matching a key in a column.

Source

fn scan_delta_index( &self, relation: &str, col_idx: usize, key: &Value, ) -> Result<Box<dyn Iterator<Item = Vec<Value>> + '_>, Error>

Returns an iterator over delta tuples matching a key in a column.

Source

fn insert(&mut self, relation: &str, tuple: Vec<Value>) -> Result<bool, Error>

Inserts a tuple into the relation (specifically into the delta/new set). Returns true if it was new.

Source

fn merge_deltas(&mut self)

Merges current deltas into the stable set of facts.

Source

fn create_relation(&mut self, relation: &str)

Ensures a relation exists in the store.

Source

fn retract(&mut self, relation: &str, tuple: &[Value]) -> Result<bool, Error>

Removes a specific tuple from the relation’s stable set. Returns true if the tuple was found and removed.

Source

fn clear(&mut self, relation: &str)

Removes all tuples from a relation (stable, delta, and next_delta).

Source

fn relation_names(&self) -> Vec<String>

Returns the names of all relations in the store.

Provided Methods§

Source

fn coalesce_temporal(&mut self, _relation: &str)

Coalesce temporal intervals for a relation. Groups facts by their non-temporal columns (all except the last 2), sorts intervals by start time, and merges overlapping/adjacent intervals. Default implementation is a no-op.

Implementors§