Skip to main content

nodedb_physical/physical_plan/vector/
collection.rs

1// SPDX-License-Identifier: Apache-2.0
2
3//! Which user collection a vector-primary direct write targets.
4//!
5//! Kept beside the operation enum rather than inside it so `op.rs` stays the
6//! single declaration of the wire shape and nothing else.
7
8use super::op::VectorOp;
9
10impl VectorOp {
11    /// The vector-primary collection a direct write targets, or `None` for
12    /// every op outside that family. `ResolveDirectWrite` reports the wrapped
13    /// write's collection so the resolve dispatch routes to the core that
14    /// owns exactly the rows the write reads.
15    pub fn direct_write_collection(&self) -> Option<&str> {
16        match self {
17            VectorOp::DirectUpsert { collection, .. }
18            | VectorOp::DirectInsert { collection, .. }
19            | VectorOp::DirectInsertIfAbsent { collection, .. }
20            | VectorOp::DirectBatchWrite { collection, .. }
21            | VectorOp::DirectDelete { collection, .. }
22            | VectorOp::DirectTruncate { collection, .. }
23            | VectorOp::DirectUpdate { collection, .. }
24            | VectorOp::ResolvedDirectWrite { collection, .. } => Some(collection.as_str()),
25            VectorOp::ResolveDirectWrite(inner) => inner.direct_write_collection(),
26            VectorOp::Search { .. }
27            | VectorOp::Insert { .. }
28            | VectorOp::BatchInsert { .. }
29            | VectorOp::MultiSearch { .. }
30            | VectorOp::Delete { .. }
31            | VectorOp::DeleteBySurrogate { .. }
32            | VectorOp::SetParams { .. }
33            | VectorOp::DropIndex { .. }
34            | VectorOp::QueryStats { .. }
35            | VectorOp::Seal { .. }
36            | VectorOp::CompactIndex { .. }
37            | VectorOp::Rebuild { .. }
38            | VectorOp::SparseInsert { .. }
39            | VectorOp::SparseSearch { .. }
40            | VectorOp::SparseDelete { .. }
41            | VectorOp::MultiVectorInsert { .. }
42            | VectorOp::MultiVectorDelete { .. }
43            | VectorOp::MultiVectorScoreSearch { .. } => None,
44        }
45    }
46}