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)]
[HKDF salt (16B)] [random nonce (12B)] [AES-256-GCM ciphertext + tag]

The inner payload is either the raw rkyv bytes for R-tree or the msgpack bytes for geohash. The complete preamble is AAD, and each envelope derives a one-use data key from its KEK, salt, nonce, and domain metadata.

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.