1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use std::collections::BTreeMap;
use marsdb_graph::{Edge, Node, PropertyValue};
use crate::ast::Literal;
/// One element of a `Value::Path` — a path is `node, edge, node, edge,
/// ..., node`, alternating, as a single `Vec`, not two parallel node/edge
/// vecs (which would create an unenforced `nodes.len() == edges.len() +
/// 1` invariant across every place a path gets built or read).
#[derive(Debug, Clone)]
pub enum PathElem {
Node(Node),
Edge(Edge),
}
#[derive(Debug, Clone)]
pub enum Value {
Node(Node),
Edge(Edge),
Property(PropertyValue),
Literal(Literal),
/// A list literal, `collect()` result, or a list-valued node/edge
/// property read back from storage (`PropertyValue::List` converts to
/// this, never a raw `Value::Property(PropertyValue::List(_))` — see
/// `executor::property_value_to_value`) — every existing list
/// operation (indexing, `size()`, `IN`, `UNWIND`, ...) pattern-matches
/// on this variant specifically, not on a property-sourced list
/// separately.
List(Vec<Value>),
/// A named path (`MATCH p = (a)-->(b) RETURN p`) or a `shortestPath()`
/// result — see `Binding::Path`'s docs (executor.rs) for how this
/// gets assembled during MATCH evaluation.
Path(Vec<PathElem>),
/// A map literal (`{a: 1, b: 2}`) — like `List`, a query-layer-only
/// concept, never persisted as a `PropertyValue` (nothing in the
/// grammar can construct a map literal to store as a node/edge
/// property directly; a `CREATE {...}` prop map's *values* are each
/// evaluated and stored individually as their own scalar
/// `PropertyValue` — see `Executor::eval_props_to_values` — a `Value::
/// Map` reaching there is a real error, not silently dropped). Its
/// other main real use is as a `date(...)`/`duration(...)`
/// construction function's argument, e.g. `date({year: 1984, month:
/// 10, day: 11})` — see `Executor::call_builtin`. `BTreeMap`, not
/// `HashMap` — canonical key order makes display/comparison
/// deterministic without a separate sort step.
Map(BTreeMap<String, Value>),
Null,
}