Transaction

Struct Transaction 

Source
pub struct Transaction<'a> { /* private fields */ }
Expand description

A database transaction.

Implementations§

Source§

impl<'a> Transaction<'a>

Source

pub fn list_catalogs(&self) -> Result<Vec<CatalogInfo>>

Catalog 一覧を取得する(オーバーレイ反映)。

Source

pub fn get_catalog(&self, name: &str) -> Result<CatalogInfo>

Catalog を取得する(オーバーレイ反映)。

Source

pub fn list_namespaces(&self, catalog_name: &str) -> Result<Vec<NamespaceInfo>>

Namespace 一覧を取得する(オーバーレイ反映)。

Source

pub fn get_namespace( &self, catalog_name: &str, namespace_name: &str, ) -> Result<NamespaceInfo>

Namespace を取得する(オーバーレイ反映)。

Source

pub fn list_tables( &self, catalog_name: &str, namespace_name: &str, ) -> Result<Vec<TableInfo>>

テーブル一覧を取得する(オーバーレイ反映)。

Source

pub fn get_table_info( &self, catalog_name: &str, namespace_name: &str, table_name: &str, ) -> Result<TableInfo>

テーブル情報を取得する(オーバーレイ反映)。

Source

pub fn create_catalog( &mut self, request: CreateCatalogRequest, ) -> Result<CatalogInfo>

Catalog を作成する(オーバーレイ反映)。

§Examples
use alopex_embedded::{CreateCatalogRequest, Database, TxnMode};

let db = Database::new();
let mut txn = db.begin(TxnMode::ReadWrite).unwrap();
let catalog = txn.create_catalog(CreateCatalogRequest::new("main")).unwrap();
assert_eq!(catalog.name, "main");
Source

pub fn delete_catalog(&mut self, name: &str, force: bool) -> Result<()>

Catalog を削除する(オーバーレイ反映)。

Source

pub fn create_namespace( &mut self, request: CreateNamespaceRequest, ) -> Result<NamespaceInfo>

Namespace を作成する(オーバーレイ反映)。

Source

pub fn delete_namespace( &mut self, catalog_name: &str, namespace_name: &str, force: bool, ) -> Result<()>

Namespace を削除する(オーバーレイ反映)。

Source

pub fn create_table(&mut self, request: CreateTableRequest) -> Result<TableInfo>

テーブルを作成する(オーバーレイ反映)。

§Examples
use alopex_embedded::{
    ColumnDefinition, CreateCatalogRequest, CreateNamespaceRequest, CreateTableRequest,
    Database, TxnMode,
};
use alopex_sql::ast::ddl::DataType;

let db = Database::new();
let mut txn = db.begin(TxnMode::ReadWrite).unwrap();
txn.create_catalog(CreateCatalogRequest::new("main")).unwrap();
txn.create_namespace(CreateNamespaceRequest::new("main", "default"))
    .unwrap();

let schema = vec![ColumnDefinition::new("id", DataType::Integer)];
let table = txn
    .create_table(
        CreateTableRequest::new("events")
            .with_catalog_name("main")
            .with_namespace_name("default")
            .with_schema(schema),
    )
    .unwrap();
assert_eq!(table.name, "events");
Source

pub fn delete_table( &mut self, catalog_name: &str, namespace_name: &str, table_name: &str, ) -> Result<()>

テーブルを削除する(オーバーレイ反映)。

Source§

impl<'a> Transaction<'a>

Source

pub fn storage_mode(&self) -> StorageMode

現在のカラムナーストレージモードを返す。

Source

pub fn write_columnar_segment( &self, table: &str, batch: RecordBatch, ) -> Result<u64>

カラムナーセグメントを書き込む(トランザクションコンテキスト利用)。

Source

pub fn read_columnar_segment( &self, table: &str, segment_id: u64, columns: Option<&[&str]>, ) -> Result<Vec<RecordBatch>>

カラムナーセグメントを読み取る(トランザクションコンテキスト利用)。

Source§

impl<'a> Transaction<'a>

Source

pub fn execute_sql(&mut self, sql: &str) -> Result<SqlResult>

SQL を実行する(外部トランザクション利用)。

同一トランザクション内の複数回呼び出しでカタログ変更が見えるよう、CatalogOverlayTransaction が所有して保持する。

§Examples
use alopex_embedded::{Database, TxnMode};

let db = Database::new();
let mut txn = db.begin(TxnMode::ReadWrite).unwrap();
txn.execute_sql("CREATE TABLE t (id INTEGER PRIMARY KEY);").unwrap();
txn.execute_sql("INSERT INTO t (id) VALUES (1);").unwrap();
txn.commit().unwrap();
Source§

impl<'a> Transaction<'a>

Source

pub fn get(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>

Retrieves the value for a given key.

Source

pub fn put(&mut self, key: &[u8], value: &[u8]) -> Result<()>

Sets a value for a given key.

Source

pub fn delete(&mut self, key: &[u8]) -> Result<()>

Deletes a key-value pair.

Source

pub fn scan_prefix( &mut self, prefix: &[u8], ) -> Result<Box<dyn Iterator<Item = (Key, Vec<u8>)> + '_>>

Scans all key-value pairs whose keys start with the given prefix.

Returns an iterator over (key, value) pairs.

Source

pub fn upsert_to_hnsw( &mut self, index_name: &str, key: &[u8], vector: &[f32], metadata: &[u8], ) -> Result<()>

HNSW にベクトルをステージング挿入/更新する。

Source

pub fn delete_from_hnsw(&mut self, index_name: &str, key: &[u8]) -> Result<bool>

HNSW からキーをステージング削除する。

Source

pub fn upsert_vector( &mut self, key: &[u8], metadata: &[u8], vector: &[f32], metric: Metric, ) -> Result<()>

Upserts a vector and metadata under the provided key after validating dimensions and metric.

A small internal index is maintained to enable scanning for similarity search.

Source

pub fn get_vector( &mut self, key: &[u8], metric: Metric, ) -> Result<Option<Vec<f32>>>

Retrieves a vector stored under the given key.

Returns None if the key does not exist. If the key exists but has a different metric than specified, returns an error.

Source

pub fn get_vectors( &mut self, keys: &[Key], metric: Metric, ) -> Result<Vec<Option<Vec<f32>>>>

Retrieves vectors stored under the given keys in a single transaction call.

Returned list order matches the input keys order. Each entry is:

  • None if the key does not exist
  • Some(Vec<f32>) if the key exists and metric matches

If any existing entry has a different metric than specified, returns an error.

Source

pub fn search_similar( &mut self, query_vector: &[f32], metric: Metric, top_k: usize, filter_keys: Option<&[Key]>, ) -> Result<Vec<SearchResult>>

Executes a flat similarity search over stored vectors using the provided metric and query.

The optional filter_keys restricts the scan to the given keys; otherwise the full vector index is scanned. Results are sorted by descending score and truncated to top_k.

Source

pub fn commit(self) -> Result<()>

Commits the transaction, applying all changes.

Source

pub fn rollback_in_place(&mut self) -> Result<()>

トランザクションを消費せずにロールバックする(失敗時の再試行を可能にする)。

Source

pub fn rollback(self) -> Result<()>

Rolls back the transaction, discarding all changes.

Trait Implementations§

Source§

impl<'a> Drop for Transaction<'a>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Transaction<'a>

§

impl<'a> !RefUnwindSafe for Transaction<'a>

§

impl<'a> Send for Transaction<'a>

§

impl<'a> Sync for Transaction<'a>

§

impl<'a> Unpin for Transaction<'a>

§

impl<'a> !UnwindSafe for Transaction<'a>

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

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

impl<T> MaybeSend for T
where T: Send,