Skip to main content

Module persist

Module persist 

Source
Expand description

R-tree checkpoint/restore for durable persistence.

§On-disk framing

Plaintext R-tree checkpoints start with the 6-byte magic RKSPT\0. The first 4 bytes are never SEGV, so detection is unambiguous.

Encrypted checkpoints use the same SEGV framing as the vector engine:

[SEGV (4B)] [version_u16_le (2B)] [cipher_alg_u8 (1B)] [kid_u8 (1B)]
[epoch (4B)] [reserved (4B)] [AES-256-GCM ciphertext of the inner payload]

The inner payload is either the raw rkyv bytes for R-tree or the msgpack bytes for geohash — the existing plaintext format. The nonce is (epoch, lsn=0), and the 16-byte preamble is used as AAD.

Storage key scheme (in redb under Namespace::Spatial):

  • {collection}\x00{field}\x00rtree → serialized R-tree entries
  • {collection}\x00{field}\x00meta → SpatialIndexMeta

Structs§

SpatialIndexMeta
Metadata for a persisted spatial index.

Enums§

RTreeCheckpointError
Errors during R-tree checkpoint operations.
SpatialIndexType
Type of spatial index.

Constants§

RTREE_FORMAT_VERSION
Current format version for rkyv-serialized R-tree snapshots.

Functions§

deserialize_meta
Deserialize index metadata from bytes.
meta_storage_key
Build the storage key for spatial index metadata.
rtree_storage_key
Build the storage key for an R-tree checkpoint.
serialize_meta
Serialize index metadata to bytes.