Crate persy

Source
Expand description

§Persy - Transactional Persistence Engine

Simple single file durable, isolated, consistent, and atomic persistence engine based on copy on write. It guarantee the persistence of data even in case of crash through a in file write ahead log, and provide simple rust APIs for store simple bytes or value associated (index) data, provide also memory management logic to keep the file size in check.

§Example

use persy::{Persy,Config};
//...
Persy::create("./target/data.persy")?;
let persy = Persy::open("./target/data.persy",Config::new())?;
let mut tx = persy.begin()?;
tx.create_segment("seg")?;
let data = vec![1;20];
tx.insert("seg", &data)?;
let prepared = tx.prepare()?;
prepared.commit()?;
for (_id,content) in persy.scan("seg")? {
    assert_eq!(content[0], 1);
    //....
}

§Example Index

use persy::{Persy,Config, ValueMode};
//...
Persy::create("./target/index_data.persy")?;
let persy = Persy::open("./target/index_data.persy",Config::new())?;
let mut tx = persy.begin()?;
tx.create_index::<i32,i32>("index", ValueMode::Cluster)?;
tx.put("index", 10, 20)?;
let prepared = tx.prepare()?;
prepared.commit()?;
for (key,values) in persy.range::<i32,i32,_>("index", ..)? {
    assert_eq!(key, 10);
    assert_eq!(values.into_iter().collect::<Vec<_>>(), vec![20]);
    //....
}

Modules§

inspect

Structs§

ByteVec
Wrapper for Vec<u8> for use it in index keys or values
Config
Persy configuration structure.
IndexId
Unique identifier of an index
IndexInfo
Index definition details
IndexIter
Index Iterator implementation for iterating on a range of keys
OpenOptions
Options, flags, configs which can be used to configure how a persy database is opened.
Persy
Main structure to operate persy storage files
PersyId
Identifier of a persistent record, can be used for read, update or delete the record
Recover
Intermediate recover status to select witch transactions to commit or rollback and list witch transactions are in a intermediate state
SegmentId
Represents a looked-up segment
SegmentIter
Iterator implementation used to scan a segment
Snapshot
Read snapshot at a specific point in time.
SnapshotSegmentIter
Iterator implementation to scan a segment at the current snapshot state.
Transaction
Transaction container, it include all the changes done in a transaction.
TransactionConfig
Configure the parameters for the transaction on the begin of a new transaction.
TransactionFinalize
prepared transaction state
TxIndexIter
Index Iterator implementation for iterating on a range of keys considering changes in transaction
TxSegmentIter
Iterator implementation to scan a segment considering in transaction changes.
ValueIter
Iterator of values relative to an index key use by get and range functions

Enums§

BeginTransactionError
CreateError
CreateIndexError
CreateSegmentError
DeleteError
DropIndexError
DropSegmentError
GenericError
IndexChangeError
IndexError
IndexOpsError
IndexPutError
IndexTypeId
Enum of all the possible Key or Value types for indexes
InsertError
OpenError
OpenMemoryError
PE
Wrapper enum for all the possible Persy errors,
PersyError
Enum of all possible errors from Persy
PrepareError
ReadError
RecoverStatus
Possible state of a transaction in the log
SegmentError
TxStrategy
Concurrent Modification Strategy for resolution of conflict on commit.
UpdateError
ValueMode
Define the behavior of the index in case a key value pair already exists

Traits§

IndexType
ToIndexId
ToSegmentId

Type Aliases§

TransactionId
Custom identifier to track the transaction in the recover phase