pub struct InfiniteDb { /* private fields */ }Expand description
Thread-safe embedded database with concurrent reads and fire-and-forget writes.
Implementations§
Source§impl InfiniteDb
impl InfiniteDb
Sourcepub fn open<P: AsRef<Path>>(dir: P) -> Result<Self>
pub fn open<P: AsRef<Path>>(dir: P) -> Result<Self>
Open or create a database at dir with default OpenOptions.
Sourcepub fn open_with_options<P: AsRef<Path>>(
dir: P,
options: &OpenOptions,
) -> Result<Self>
pub fn open_with_options<P: AsRef<Path>>( dir: P, options: &OpenOptions, ) -> Result<Self>
Open or create a database at dir with explicit tuning and format version.
Sourcepub fn branch_head(&self, branch: BranchId) -> Option<SnapshotId>
pub fn branch_head(&self, branch: BranchId) -> Option<SnapshotId>
Head snapshot pointer for branch.
Sourcepub fn conflicts(&self) -> &ConflictQueue
pub fn conflicts(&self) -> &ConflictQueue
Conflict queue populated during sync replication (requires sync feature).
Sourcepub fn format_version(&self) -> u32
pub fn format_version(&self) -> u32
On-disk format version (2, 3, or 4) for this database directory.
Sourcepub fn register_space(&self, config: SpaceConfig) -> Result<(), String>
pub fn register_space(&self, config: SpaceConfig) -> Result<(), String>
Register a new space and persist catalog metadata. Required before writes to that space.
Sourcepub fn insert(
&self,
space: SpaceId,
point: DimensionVector,
data: Vec<u8>,
) -> Result<RevisionId>
pub fn insert( &self, space: SpaceId, point: DimensionVector, data: Vec<u8>, ) -> Result<RevisionId>
Fire-and-forget insert on main. Blocks only when the target queue is full.
Sourcepub fn insert_on_branch(
&self,
branch: BranchId,
space: SpaceId,
point: DimensionVector,
data: Vec<u8>,
) -> Result<RevisionId>
pub fn insert_on_branch( &self, branch: BranchId, space: SpaceId, point: DimensionVector, data: Vec<u8>, ) -> Result<RevisionId>
Fire-and-forget insert on a branch (overlay for non-main branches).
Sourcepub fn delete(
&self,
space: SpaceId,
point: DimensionVector,
) -> Result<RevisionId>
pub fn delete( &self, space: SpaceId, point: DimensionVector, ) -> Result<RevisionId>
Fire-and-forget delete on main.
Sourcepub fn delete_on_branch(
&self,
branch: BranchId,
space: SpaceId,
point: DimensionVector,
) -> Result<RevisionId>
pub fn delete_on_branch( &self, branch: BranchId, space: SpaceId, point: DimensionVector, ) -> Result<RevisionId>
Fire-and-forget delete on a branch.
Sourcepub fn create_branch(
&self,
name: &str,
from: BranchId,
) -> Result<BranchId, String>
pub fn create_branch( &self, name: &str, from: BranchId, ) -> Result<BranchId, String>
Fork a new branch from from at the current revision.
Sourcepub fn merge_branch(
&self,
target: BranchId,
source: BranchId,
strategy: MergeStrategy,
resolver: Option<Box<dyn Fn(MergeConflict) -> Record + Send + Sync>>,
) -> Result<MergeResult>
pub fn merge_branch( &self, target: BranchId, source: BranchId, strategy: MergeStrategy, resolver: Option<Box<dyn Fn(MergeConflict) -> Record + Send + Sync>>, ) -> Result<MergeResult>
Three-way merge source into target (usually main).
Sourcepub fn query_on_branch(
&self,
branch: BranchId,
space: SpaceId,
as_of: Option<RevisionId>,
) -> Result<Vec<Record>>
pub fn query_on_branch( &self, branch: BranchId, space: SpaceId, as_of: Option<RevisionId>, ) -> Result<Vec<Record>>
Query space through a branch overlay.
Sourcepub fn enqueue_batch(&self, jobs: Vec<WriteJob>) -> Result<()>
pub fn enqueue_batch(&self, jobs: Vec<WriteJob>) -> Result<()>
Enqueue writes across multiple spaces (ordered by space id).
Caller-supplied WriteJob::revision values must not exceed the global
revision counter; this method advances the counter to the maximum job revision.
Sourcepub fn query(
&self,
space: SpaceId,
as_of: Option<RevisionId>,
) -> Result<Vec<Record>>
pub fn query( &self, space: SpaceId, as_of: Option<RevisionId>, ) -> Result<Vec<Record>>
Query all live records in space on main, optionally capped at as_of.
Sourcepub fn query_bbox(
&self,
space: SpaceId,
min: DimensionVector,
max: DimensionVector,
as_of: Option<RevisionId>,
) -> Result<Vec<Record>>
pub fn query_bbox( &self, space: SpaceId, min: DimensionVector, max: DimensionVector, as_of: Option<RevisionId>, ) -> Result<Vec<Record>>
Bounding-box query on main.
Sourcepub fn query_bbox_on_branch(
&self,
branch: BranchId,
space: SpaceId,
min: DimensionVector,
max: DimensionVector,
as_of: Option<RevisionId>,
) -> Result<Vec<Record>>
pub fn query_bbox_on_branch( &self, branch: BranchId, space: SpaceId, min: DimensionVector, max: DimensionVector, as_of: Option<RevisionId>, ) -> Result<Vec<Record>>
Bounding-box query through a branch overlay.
Sourcepub fn flush(&self, space: SpaceId) -> Result<()>
pub fn flush(&self, space: SpaceId) -> Result<()>
Flush pending writes for one space to durable storage without syncing all spaces.
Sourcepub fn sync(&self) -> Result<()>
pub fn sync(&self) -> Result<()>
Flush all write queues and persist metadata. Call after writes to make data queryable.
Sourcepub fn read(&self) -> ReadTxn<'_>
pub fn read(&self) -> ReadTxn<'_>
Begin a concurrent read transaction pinned at the current revision.
Sourcepub fn io_stats(&self) -> IoStats
pub fn io_stats(&self) -> IoStats
I/O queue depth and write-path counters across all backend threads.
Sourcepub fn space_shard_count(&self) -> usize
pub fn space_shard_count(&self) -> usize
Number of I/O shards (1 for format v2, per-space or per-Hilbert-shard for v3/v4).