Skip to main content

Crate cynos_storage

Crate cynos_storage 

Source
Expand description

Cynos Storage - Storage layer for Cynos in-memory database.

This crate provides the storage layer including:

  • RowStore: Row storage with index maintenance
  • TableCache: Multi-table cache management
  • Journal: Change tracking for transactions
  • Transaction: Transaction management with rollback support
  • ConstraintChecker: Constraint validation
  • LockManager: Concurrent access control

§Example

use cynos_storage::{TableCache, Transaction};
use cynos_core::schema::TableBuilder;
use cynos_core::{DataType, Row, Value};

// Create a cache and table
let mut cache = TableCache::new();
let schema = TableBuilder::new("users")
    .unwrap()
    .add_column("id", DataType::Int64)
    .unwrap()
    .add_column("name", DataType::String)
    .unwrap()
    .add_primary_key(&["id"], false)
    .unwrap()
    .build()
    .unwrap();
cache.create_table(schema).unwrap();

// Use a transaction
let mut tx = Transaction::begin();
let row = Row::new(1, vec![Value::Int64(1), Value::String("Alice".into())]);
tx.insert(&mut cache, "users", row).unwrap();
tx.commit().unwrap();

assert_eq!(cache.get_table("users").unwrap().len(), 1);

Re-exports§

pub use cache::TableCache;
pub use constraint::ConstraintChecker;
pub use journal::Journal;
pub use journal::JournalEntry;
pub use journal::TableDiff;
pub use lock::LockManager;
pub use lock::LockType;
pub use row_store::BTreeIndexStore;
pub use row_store::HashIndexStore;
pub use row_store::IndexStore;
pub use row_store::RowStore;
pub use transaction::Transaction;
pub use transaction::TransactionId;
pub use transaction::TransactionState;

Modules§

cache
Cache management for Cynos database.
constraint
Constraint checking for Cynos database.
journal
Journal for tracking changes in Cynos database.
lock
Lock management for Cynos database.
row_store
Row storage for Cynos database.
transaction
Transaction management for Cynos database.