Update statistics incrementally for a document's fields. Called on every PointPut. Loads existing stats for each field, observes the new value, and persists.
(
&self,
tenant_id: u64,
collection: &str,
doc: &serde_json::Value,
)
| 255 | /// Called on every PointPut. Loads existing stats for each field, |
| 256 | /// observes the new value, and persists. |
| 257 | pub fn observe_document( |
| 258 | &self, |
| 259 | tenant_id: u64, |
| 260 | collection: &str, |
| 261 | doc: &serde_json::Value, |
| 262 | ) -> crate::Result<()> { |
| 263 | if let Some(obj) = doc.as_object() { |
| 264 | for (field, value) in obj { |
| 265 | let mut stats = self.get(tenant_id, collection, field)?.unwrap_or_default(); |
| 266 | stats.observe(Some(value)); |
| 267 | self.put(tenant_id, collection, field, &stats)?; |
| 268 | } |
| 269 | } |
| 270 | Ok(()) |
| 271 | } |
| 272 | |
| 273 | /// Update statistics within an externally-owned write transaction. |
| 274 | /// |