MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / extract_value

Function extract_value

nodedb-query/src/msgpack_scan/aggregate_helpers.rs:51–61  ·  view source on GitHub ↗

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>)

Source from the content-addressed store, hash-verified

49/// Extract a field as `Value`. Uses direct msgpack→Value for scalars;
50/// falls back to full document decode only for complex types.
51pub 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.

Callers 2

extract_non_nullFunction · 0.85
feedMethod · 0.85

Calls 5

extract_fieldFunction · 0.85
value_from_msgpackFunction · 0.85
eval_exprFunction · 0.70
read_valueFunction · 0.70
okMethod · 0.45

Tested by

no test coverage detected