Skip to main content

RelationStore

Struct RelationStore 

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

Storage for named relations as GPU buffers

RelationStore manages a collection of named relations, each stored as a CudaBuffer. It provides CRUD operations for relation management during query execution.

§Thread Safety

This implementation is NOT thread-safe. It is designed for single-threaded runtime execution in the MVP.

§Example

use xlog_runtime::RelationStore;
use xlog_cuda::CudaBuffer;
use xlog_core::Schema;

let mut store = RelationStore::new(provider);

// Add a relation
store.put("edge", buffer);

// Check if relation exists
if store.contains("edge") {
    let edge = store.get("edge").unwrap();
}

// Remove a relation
let removed = store.remove("edge");

Implementations§

Source§

impl RelationStore

Source

pub fn new(provider: Arc<CudaKernelProvider>) -> Self

Create a new empty relation store

Source

pub fn get(&self, name: &str) -> Option<&CudaBuffer>

Get a reference to a relation by name

§Arguments
  • name - The name of the relation
§Returns

Some(&CudaBuffer) if the relation exists, None otherwise

Source

pub fn get_mut(&mut self, name: &str) -> Option<&mut CudaBuffer>

Get a mutable reference to a relation by name

§Arguments
  • name - The name of the relation
§Returns

Some(&mut CudaBuffer) if the relation exists, None otherwise

Source

pub fn get_with_version(&self, name: &str) -> Option<(&CudaBuffer, u64)>

Get a relation by name along with its current version.

Source

pub fn version(&self, name: &str) -> Option<u64>

Get the current version for a relation.

Source

pub fn put(&mut self, name: &str, buffer: CudaBuffer)

Store a relation with the given name

If a relation with the same name already exists, it will be replaced.

§Arguments
  • name - The name of the relation
  • buffer - The GPU buffer containing the relation data
Source

pub fn get_or_insert_empty( &mut self, name: &str, schema: &Schema, ) -> Result<&CudaBuffer>

Get a relation by name, or insert an empty buffer with the given schema

This is useful for semi-naive evaluation where delta relations may not exist yet on the first iteration. If the relation doesn’t exist, an empty buffer with the given schema is inserted into the store.

§Arguments
  • name - The name of the relation
  • schema - The schema to use if creating an empty buffer
§Returns

A reference to the existing buffer, or the newly inserted empty buffer

Source

pub fn get_or_insert_empty_mut( &mut self, name: &str, schema: &Schema, ) -> Result<&mut CudaBuffer>

Get a mutable reference to a relation, or insert an empty buffer with the given schema

This is useful for semi-naive evaluation where delta relations may not exist yet on the first iteration. If the relation doesn’t exist, an empty buffer with the given schema is inserted into the store.

§Arguments
  • name - The name of the relation
  • schema - The schema to use if creating an empty buffer
§Returns

A mutable reference to the existing buffer, or the newly inserted empty buffer

Source

pub fn contains(&self, name: &str) -> bool

Check if a relation exists in the store

§Arguments
  • name - The name of the relation
§Returns

true if the relation exists, false otherwise

Source

pub fn remove(&mut self, name: &str) -> Option<CudaBuffer>

Remove a relation from the store

§Arguments
  • name - The name of the relation
§Returns

Some(CudaBuffer) if the relation existed, None otherwise

Source

pub fn clear(&mut self)

Clear all relations from the store

This removes all stored relations. The GPU memory will be freed when the CudaBuffer instances are dropped.

Source

pub fn len(&self) -> usize

Get the number of relations in the store

Source

pub fn is_empty(&self) -> bool

Check if the store is empty

Source

pub fn names(&self) -> impl Iterator<Item = &str>

Get an iterator over relation names

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

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,