pub struct InfiniteDb { /* private fields */ }Expand description
Top-level embedded database handle and diagnostics.
The embedded database handle. Not Send/Sync — create one per thread
or wrap in a Mutex for multi-threaded access.
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 in dir. Replays the WAL on first open.
Sourcepub fn register_space(&mut self, config: SpaceConfig) -> Result<(), String>
pub fn register_space(&mut self, config: SpaceConfig) -> Result<(), String>
Register a new space. Must be called before inserting records into it.
Sourcepub fn insert(
&mut self,
space: SpaceId,
point: DimensionVector,
data: Vec<u8>,
) -> Result<RevisionId>
pub fn insert( &mut self, space: SpaceId, point: DimensionVector, data: Vec<u8>, ) -> Result<RevisionId>
Insert or update a record. Appends a new revision to the WAL.
The record is buffered in memory; call flush() to seal it into a block.
Sourcepub fn delete(
&mut self,
space: SpaceId,
point: DimensionVector,
) -> Result<RevisionId>
pub fn delete( &mut self, space: SpaceId, point: DimensionVector, ) -> Result<RevisionId>
Logically delete a record at point in space.
Sourcepub fn flush(&mut self, space: SpaceId) -> Result<()>
pub fn flush(&mut self, space: SpaceId) -> Result<()>
Seal all buffered records for space into a new block on disk.
Sourcepub fn current_snapshot(&self, space: SpaceId) -> Option<SnapshotId>
pub fn current_snapshot(&self, space: SpaceId) -> Option<SnapshotId>
Return the current snapshot ID for space.
Sourcepub fn query(
&mut self,
space: SpaceId,
as_of: Option<RevisionId>,
) -> Result<Vec<Record>>
pub fn query( &mut self, space: SpaceId, as_of: Option<RevisionId>, ) -> Result<Vec<Record>>
Scan all live records in space, optionally capped at as_of.
Full-space scan — no spatial filtering. Use query_bbox to filter by coordinates.
Sourcepub fn query_bbox(
&mut self,
space: SpaceId,
min: DimensionVector,
max: DimensionVector,
as_of: Option<RevisionId>,
) -> Result<Vec<Record>>
pub fn query_bbox( &mut self, space: SpaceId, min: DimensionVector, max: DimensionVector, as_of: Option<RevisionId>, ) -> Result<Vec<Record>>
Bounding-box query in N dimensions.
Returns every live record in space whose point satisfies
min[i] <= point[i] <= max[i] on every axis simultaneously.
Works correctly for any dimensionality (1–16 dims). A Hilbert-key
interval is used to prune candidate blocks at the block level; an
exact within() check per record eliminates any false positives caused
by the Hilbert curve mapping a bounding box to many disjoint intervals.
min and max must have the same number of coordinates as the points
stored in the space.
Sourcepub fn query_subscope(
&mut self,
space: SpaceId,
parent_coords: &[u32],
as_of: Option<RevisionId>,
) -> Result<Vec<Record>>
pub fn query_subscope( &mut self, space: SpaceId, parent_coords: &[u32], as_of: Option<RevisionId>, ) -> Result<Vec<Record>>
Sub-space query: pins the first parent_coords.len() dimensions to exact
values and leaves the remaining inner dimensions fully open (0..u32::MAX).
This is the idiomatic way to retrieve all property records for a specific parent element in the nested Hilbert design:
// All load properties of element 42:
db.query_subscope(SPACE_LOADS, &[42], None);Sourcepub fn create_branch(
&mut self,
name: impl Into<String>,
from: BranchId,
) -> Result<BranchId, String>
pub fn create_branch( &mut self, name: impl Into<String>, from: BranchId, ) -> Result<BranchId, String>
Create a new branch forked from an existing one at the current revision.
Sourcepub fn memory_stats(&self) -> MemoryStats
pub fn memory_stats(&self) -> MemoryStats
Returns a snapshot of current memory and cache usage.