Skip to main content

Database

Struct Database 

Source
pub struct Database { /* private fields */ }

Implementations§

Source§

impl Database

Source

pub fn set_spill_threshold(&self, bytes: u64)

Override the spill threshold at runtime (via SET spill_threshold). A value of 0 explicitly disables spilling.

Source

pub fn effective_spill_threshold(&self) -> u64

Get the effective spill threshold in bytes.

Priority:

  1. Runtime override (via SET spill_threshold; 0 = explicitly disabled)
  2. config.spill_threshold
  3. 80% of buffer_pool_size
  4. 0 (disabled)
Source

pub fn spiller(&self) -> Option<Arc<Spiller>>

Create a Spiller instance using the current database configuration.

Returns None if spilling is disabled (threshold is 0).

Source

pub fn storage_driver(&self) -> StorageDriver

Create a [StorageDriver] for programmatic storage-level access (page counts, buffer stats, file sizes, table counts) without Cypher.

Source

pub fn catalog(&self) -> Arc<Mutex<Catalog>>

Get a reference to the schema catalog for programmatic metadata access.

Source

pub fn table_catalog(&self) -> Arc<TableCatalog>

Get the data table catalog for programmatic data access.

Prefer using the unified DDL methods on Database instead of accessing the table catalog directly.

Source

pub fn create_node_table( &self, name: String, columns: Vec<CatalogColumn>, ) -> Result<u64, String>

Create a node table: data table + serial sequences + ART index.

The schema entry is created by the binder during bind(). This method creates the storage-level table and associated resources.

Source

pub fn create_rel_table( &self, name: String, src_table_id: u64, dst_table_id: u64, columns: Vec<CatalogColumn>, ) -> Result<u64, String>

Create a rel table: data table.

The schema entry is created by the binder during bind(). This method creates the storage-level table.

Source

pub fn drop_table(&self, name: &str) -> Result<(), String>

Drop a table: serial sequences + data table + schema entry.

Source

pub fn refresh_vector_indexes(&self, _table_ids: &[u64])

No-op when the vector extension is not compiled in.

Source

pub fn create_art_index( &self, table_name: &str, index_name: &str, ) -> Result<(), String>

Create an ART index on a node table: data index.

The schema entry is created by the binder during bind().

Source

pub fn drop_art_index( &self, table_name: &str, _index_name: &str, ) -> Result<(), String>

Drop an ART index from a node table: data index + schema entry.

Source

pub fn table_num_rows(&self, name: &str) -> u64

Get the number of rows in a table by name.

Source

pub fn get_table_id(&self, name: &str) -> Result<Option<u64>, String>

Get table IDs for write operations (used by transaction locking).

Propagates a poisoned catalog lock instead of silently treating it as a missing table (Audit 2 NIT).

Source

pub fn catalog_file_path(&self) -> PathBuf

Path of the persisted catalog file for this database.

Source

pub fn connect_tcp(addr: impl Into<String>) -> Result<RemoteDatabase, String>

Connect to a remote Akar server (embedded server mode, P47).

The server process owns the Database instance and its exclusive file lock; remote clients only talk to the server over TCP and never open the database directory themselves. Multiple processes can therefore access the same database concurrently: one writer via the server plus any number of read-only clients (and additional writers when concurrent_writes is enabled).

See crate::remote::RemoteDatabase for the returned handle’s API.

Source

pub fn is_in_memory(&self) -> bool

Returns true when the database runs fully in-memory (:memory:), in which case catalog persistence is skipped.

Source

pub fn persist_catalog(&self) -> Result<(), String>

Persist the system catalog to disk.

Called after every DDL statement so schema changes survive restarts. The write is atomic (temp file + rename) and no-ops for :memory: databases.

Source

pub fn new( db_path: impl Into<PathBuf>, config: SystemConfig, ) -> Result<Self, String>

Open or create a database at the given path.

§Arguments
  • db_path — filesystem path where database files are stored.
  • config — buffer pool size, thread count, etc.
§Errors

Returns Err if the path is not writable or if existing data is corrupt.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more