Scan sparse/document engine → standard msgpack. Handles both schemaless (msgpack) and strict (Binary Tuple) formats.
(
&self,
tid: u64,
collection: &str,
limit: usize,
)
| 218 | /// Scan sparse/document engine → standard msgpack. |
| 219 | /// Handles both schemaless (msgpack) and strict (Binary Tuple) formats. |
| 220 | pub(super) fn scan_sparse( |
| 221 | &self, |
| 222 | tid: u64, |
| 223 | collection: &str, |
| 224 | limit: usize, |
| 225 | ) -> crate::Result<Vec<(String, Vec<u8>)>> { |
| 226 | let docs = self.sparse.scan_documents(tid, collection, limit)?; |
| 227 | |
| 228 | let config_key = (crate::types::TenantId::new(tid), collection.to_string()); |
| 229 | let strict_schema = self.doc_configs.get(&config_key).and_then(|c| { |
| 230 | if let nodedb_physical::physical_plan::StorageMode::Strict { ref schema } = |
| 231 | c.storage_mode |
| 232 | { |
| 233 | Some(schema.clone()) |
| 234 | } else { |
| 235 | None |
| 236 | } |
| 237 | }); |
| 238 | |
| 239 | if let Some(ref schema) = strict_schema { |
| 240 | // Strict: Binary Tuple → msgpack → inject "id". |
| 241 | let mut normalized = Vec::with_capacity(docs.len()); |
| 242 | for (id, raw) in docs { |
| 243 | let mp = super::strict_format::binary_tuple_to_msgpack(&raw, schema) |
| 244 | .unwrap_or_else(|| super::doc_format::json_to_msgpack(&raw)); |
| 245 | let mp = msgpack_scan::inject_str_field(&mp, "id", &id); |
| 246 | normalized.push((id, mp)); |
| 247 | } |
| 248 | Ok(normalized) |
| 249 | } else { |
| 250 | // Schemaless: ensure standard msgpack, inject `id` field. |
| 251 | let mut normalized = Vec::with_capacity(docs.len()); |
| 252 | for (id, raw) in docs { |
| 253 | let mp = super::doc_format::json_to_msgpack(&raw); |
| 254 | let mp = msgpack_scan::inject_str_field(&mp, "id", &id); |
| 255 | normalized.push((id, mp)); |
| 256 | } |
| 257 | Ok(normalized) |
| 258 | } |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | /// Convert a single row from a `DecodedColumn` to a `nodedb_types::value::Value`. |
no test coverage detected