Extract a field as `Value`. Uses direct msgpack→Value for scalars; falls back to full document decode only for complex types.
(doc: &[u8], field: &str, expr: Option<&SqlExpr>)
| 49 | /// Extract a field as `Value`. Uses direct msgpack→Value for scalars; |
| 50 | /// falls back to full document decode only for complex types. |
| 51 | pub fn extract_value(doc: &[u8], field: &str, expr: Option<&SqlExpr>) -> Option<Value> { |
| 52 | if let Some(expr) = expr { |
| 53 | return eval_expr(doc, expr); |
| 54 | } |
| 55 | let (start, end) = extract_field(doc, 0, field)?; |
| 56 | if let Some(v) = read_value(doc, start) { |
| 57 | return Some(v); |
| 58 | } |
| 59 | let field_bytes = &doc[start..end]; |
| 60 | nodedb_types::json_msgpack::value_from_msgpack(field_bytes).ok() |
| 61 | } |
| 62 | |
| 63 | /// Extract a field or expression result as raw msgpack bytes. |
| 64 | /// Used by `count_distinct`, `approx_count_distinct`, `approx_topk`, etc. |
no test coverage detected