pub struct Db { /* private fields */ }Expand description
Implementations§
Source§impl Db
impl Db
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Opens a database at the given path.
The path can be:
- A directory path: files will be created as
<path>.ndband<path>.wal - An explicit
.ndbor.walpath: the other file is inferred
Returns an error if the database cannot be opened.
Sourcepub fn begin_read(&self) -> ReadTxn
pub fn begin_read(&self) -> ReadTxn
Begins a read-only transaction.
The returned ReadTxn provides a consistent view of the database
at the time of creation. It can be used concurrently with other
read transactions and will not see writes that commit after its creation.
Sourcepub fn snapshot(&self) -> DbSnapshot
pub fn snapshot(&self) -> DbSnapshot
Creates a snapshot for query execution.
Returns a DbSnapshot that implements GraphSnapshot trait,
suitable for use with the query engine.
Sourcepub fn begin_write(&self) -> WriteTxn<'_>
pub fn begin_write(&self) -> WriteTxn<'_>
Begins a write transaction.
Write transactions are exclusive - only one can exist at a time.
The transaction must be explicitly committed with commit().
§Panics
Panics if another write transaction is already in progress.
Sourcepub fn compact(&self) -> Result<()>
pub fn compact(&self) -> Result<()>
Triggers a compaction operation.
Compaction merges frozen MemTables into CSR segments and removes tombstoned entries. This is a potentially expensive operation that should be done during maintenance windows.
Sourcepub fn checkpoint(&self) -> Result<()>
pub fn checkpoint(&self) -> Result<()>
Creates a durability checkpoint.
In MVP, this is equivalent to compact(). Future versions may
implement lightweight checkpoints that don’t require full compaction.