1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// SPDX-License-Identifier: Apache-2.0
//! `SpatialSegmentExt` — pagedb segment operations for R-tree checkpoint data.
//!
//! The `StorageEngine` trait handles sparse, sorted, key-value state. For R-tree
//! checkpoint blobs (one per (collection, field) pair, potentially large,
//! sequentially read on cold-open restore) pagedb segments are the appropriate
//! backing. A single segment per (collection, field) reduces B+ tree pressure from
//! O(rtree_node_count) entries to O(1) per index.
//!
//! The following keys remain on the B+ tree (`Namespace::Spatial`):
//! - `spatial:_collections` — `Vec<(String, String)>` catalog (collection, field)
//! - `spatial:_next_id` — `u64` next entry ID
//! - `spatial:{collection}:{field}:docmap` — doc_id → entry_id mapping
//!
//! Only the `spatial:{collection}:{field}:rtree` blob (CRC32C-wrapped R-tree
//! checkpoint bytes) moves to pagedb segments.
//!
//! Only compiled on non-WASM targets. WASM stays on the KV blob path.
use crateLiteError;
/// Extension trait: write, open, and delete R-tree checkpoint segments backed
/// by pagedb encrypted segment files.
///
/// One segment per (collection, field) pair (e.g. `"orders"`, `"location"`).
/// The segment contains the CRC32C-wrapped R-tree checkpoint bytes exactly as
/// produced by `crate::storage::checksum::wrap` — no additional framing beyond
/// the 8-byte length-prefix envelope used to survive pagedb's page-boundary
/// zero-padding.
///
/// This trait is object-safe so `StorageEngine` implementations can return
/// `Option<&dyn SpatialSegmentExt>` via `as_spatial_segment_ext()`.