Get a document and deserialize from MessagePack to JSON.
(&self, collection: &str, doc_id: &str)
| 8 | impl<'a> DocumentEngine<'a> { |
| 9 | /// Get a document and deserialize from MessagePack to JSON. |
| 10 | pub fn get(&self, collection: &str, doc_id: &str) -> crate::Result<Option<serde_json::Value>> { |
| 11 | let bytes_opt = if self.is_bitemporal(collection) { |
| 12 | self.sparse |
| 13 | .versioned_get_current(self.tenant_id, collection, doc_id)? |
| 14 | } else { |
| 15 | self.sparse.get(self.tenant_id, collection, doc_id)? |
| 16 | }; |
| 17 | match bytes_opt { |
| 18 | Some(bytes) => { |
| 19 | let rmpv_val = rmpv::decode::read_value(&mut bytes.as_slice()).map_err(|e| { |
| 20 | crate::Error::Serialization { |
| 21 | format: "msgpack".into(), |
| 22 | detail: format!("decode: {e}"), |
| 23 | } |
| 24 | })?; |
| 25 | Ok(Some(rmpv_to_json(&rmpv_val))) |
| 26 | } |
| 27 | None => Ok(None), |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | /// Get raw MessagePack bytes (zero-copy path for DataFusion UDFs). |
| 32 | pub fn get_raw(&self, collection: &str, doc_id: &str) -> crate::Result<Option<Vec<u8>>> { |