pub struct Transaction<'a> { /* private fields */ }Expand description
A database transaction.
Implementations§
Source§impl<'a> Transaction<'a>
impl<'a> Transaction<'a>
Sourcepub fn list_catalogs(&self) -> Result<Vec<CatalogInfo>>
pub fn list_catalogs(&self) -> Result<Vec<CatalogInfo>>
Catalog 一覧を取得する(オーバーレイ反映)。
Sourcepub fn get_catalog(&self, name: &str) -> Result<CatalogInfo>
pub fn get_catalog(&self, name: &str) -> Result<CatalogInfo>
Catalog を取得する(オーバーレイ反映)。
Sourcepub fn list_namespaces(&self, catalog_name: &str) -> Result<Vec<NamespaceInfo>>
pub fn list_namespaces(&self, catalog_name: &str) -> Result<Vec<NamespaceInfo>>
Namespace 一覧を取得する(オーバーレイ反映)。
Sourcepub fn get_namespace(
&self,
catalog_name: &str,
namespace_name: &str,
) -> Result<NamespaceInfo>
pub fn get_namespace( &self, catalog_name: &str, namespace_name: &str, ) -> Result<NamespaceInfo>
Namespace を取得する(オーバーレイ反映)。
Sourcepub fn list_tables(
&self,
catalog_name: &str,
namespace_name: &str,
) -> Result<Vec<TableInfo>>
pub fn list_tables( &self, catalog_name: &str, namespace_name: &str, ) -> Result<Vec<TableInfo>>
テーブル一覧を取得する(オーバーレイ反映)。
Sourcepub fn get_table_info(
&self,
catalog_name: &str,
namespace_name: &str,
table_name: &str,
) -> Result<TableInfo>
pub fn get_table_info( &self, catalog_name: &str, namespace_name: &str, table_name: &str, ) -> Result<TableInfo>
テーブル情報を取得する(オーバーレイ反映)。
Sourcepub fn create_catalog(
&mut self,
request: CreateCatalogRequest,
) -> Result<CatalogInfo>
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");Sourcepub fn delete_catalog(&mut self, name: &str, force: bool) -> Result<()>
pub fn delete_catalog(&mut self, name: &str, force: bool) -> Result<()>
Catalog を削除する(オーバーレイ反映)。
Sourcepub fn create_namespace(
&mut self,
request: CreateNamespaceRequest,
) -> Result<NamespaceInfo>
pub fn create_namespace( &mut self, request: CreateNamespaceRequest, ) -> Result<NamespaceInfo>
Namespace を作成する(オーバーレイ反映)。
Sourcepub fn delete_namespace(
&mut self,
catalog_name: &str,
namespace_name: &str,
force: bool,
) -> Result<()>
pub fn delete_namespace( &mut self, catalog_name: &str, namespace_name: &str, force: bool, ) -> Result<()>
Namespace を削除する(オーバーレイ反映)。
Sourcepub fn create_table(&mut self, request: CreateTableRequest) -> Result<TableInfo>
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§impl<'a> Transaction<'a>
impl<'a> Transaction<'a>
Sourcepub fn storage_mode(&self) -> StorageMode
pub fn storage_mode(&self) -> StorageMode
現在のカラムナーストレージモードを返す。
Sourcepub fn write_columnar_segment(
&self,
table: &str,
batch: RecordBatch,
) -> Result<u64>
pub fn write_columnar_segment( &self, table: &str, batch: RecordBatch, ) -> Result<u64>
カラムナーセグメントを書き込む(トランザクションコンテキスト利用)。
Sourcepub fn read_columnar_segment(
&self,
table: &str,
segment_id: u64,
columns: Option<&[&str]>,
) -> Result<Vec<RecordBatch>>
pub fn read_columnar_segment( &self, table: &str, segment_id: u64, columns: Option<&[&str]>, ) -> Result<Vec<RecordBatch>>
カラムナーセグメントを読み取る(トランザクションコンテキスト利用)。
Source§impl<'a> Transaction<'a>
impl<'a> Transaction<'a>
Sourcepub fn execute_sql(&mut self, sql: &str) -> Result<SqlResult>
pub fn execute_sql(&mut self, sql: &str) -> Result<SqlResult>
SQL を実行する(外部トランザクション利用)。
同一トランザクション内の複数回呼び出しでカタログ変更が見えるよう、CatalogOverlay は
Transaction が所有して保持する。
§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>
impl<'a> Transaction<'a>
Sourcepub fn get(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>
pub fn get(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>
Retrieves the value for a given key.
Sourcepub fn scan_prefix(
&mut self,
prefix: &[u8],
) -> Result<Box<dyn Iterator<Item = (Key, Vec<u8>)> + '_>>
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.
Sourcepub fn upsert_to_hnsw(
&mut self,
index_name: &str,
key: &[u8],
vector: &[f32],
metadata: &[u8],
) -> Result<()>
pub fn upsert_to_hnsw( &mut self, index_name: &str, key: &[u8], vector: &[f32], metadata: &[u8], ) -> Result<()>
HNSW にベクトルをステージング挿入/更新する。
Sourcepub fn delete_from_hnsw(&mut self, index_name: &str, key: &[u8]) -> Result<bool>
pub fn delete_from_hnsw(&mut self, index_name: &str, key: &[u8]) -> Result<bool>
HNSW からキーをステージング削除する。
Sourcepub fn upsert_vector(
&mut self,
key: &[u8],
metadata: &[u8],
vector: &[f32],
metric: Metric,
) -> Result<()>
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.
Sourcepub fn get_vector(
&mut self,
key: &[u8],
metric: Metric,
) -> Result<Option<Vec<f32>>>
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.
Sourcepub fn get_vectors(
&mut self,
keys: &[Key],
metric: Metric,
) -> Result<Vec<Option<Vec<f32>>>>
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:
Noneif the key does not existSome(Vec<f32>)if the key exists and metric matches
If any existing entry has a different metric than specified, returns an error.
Sourcepub fn search_similar(
&mut self,
query_vector: &[f32],
metric: Metric,
top_k: usize,
filter_keys: Option<&[Key]>,
) -> Result<Vec<SearchResult>>
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.
Sourcepub fn rollback_in_place(&mut self) -> Result<()>
pub fn rollback_in_place(&mut self) -> Result<()>
トランザクションを消費せずにロールバックする(失敗時の再試行を可能にする)。