Skip to main content

nodedb_physical/
convert_context.rs

1// SPDX-License-Identifier: Apache-2.0
2
3//! Deployment-neutral context threaded through the shared `SqlPlan →
4//! PhysicalPlan` converter helpers in `crate::convert`.
5//!
6//! Carries only fields both Origin and Lite can supply. Origin-only state
7//! (WAL handle, array catalog, credential store, retention registries) lives
8//! on Origin's wrapper context and is consumed by Origin-only converter
9//! arms (array DDL/DML, timeseries-retention tier-down) that the shared
10//! helpers never touch.
11
12use std::sync::Arc;
13
14use nodedb_types::DatabaseId;
15
16use crate::SurrogateAssigner;
17
18/// Inputs every shared converter helper needs.
19///
20/// Origin and Lite construct this with the same shape; their visitor
21/// implementations wrap it (Origin adds catalog/WAL handles, Lite passes
22/// it through unchanged).
23pub struct SharedConvertContext {
24    /// Database scope for vShard computation. All
25    /// `VShardId::from_collection_in_database` calls inside the converter
26    /// must use this value so collections in different databases route to
27    /// distinct shards.
28    pub database_id: DatabaseId,
29
30    /// Per-tenant maximum vector dimension (0 = unlimited). Checked during
31    /// `VectorPrimaryInsert` lowering.
32    pub max_vector_dim: u32,
33
34    /// `true` when the node is running in cluster mode with a live
35    /// topology. Origin's array DML/query converters emit `ClusterArray`
36    /// variants when set; single-node Origin and Lite leave this `false`.
37    pub cluster_enabled: bool,
38
39    /// CP-side surrogate assigner. Threaded into INSERT/UPSERT/KV-INSERT
40    /// helpers to bind `(collection, pk_bytes)` → `Surrogate` before the
41    /// op crosses any plane boundary. `None` only for sub-planners that
42    /// never lower to surrogate-bearing variants.
43    pub surrogate_assigner: Option<Arc<dyn SurrogateAssigner>>,
44}