Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/kleene

crates/kleene-gql/src/lib.rs

//! GQL read queries (ISO/IEC 39075), a client of kleene-plan.
//!
//! | Part | Here |
//! |---|---|
//! | Text | [`parse`]: `MATCH` node and edge patterns with labels and property maps (`(a:Func {name: "main"})`, read as `a.name = "main"` in the clause's WHERE; `(a:Func)`, `(a IS Func)`, `(a:Func\|Lib)` for either label, `-[:CALLS]->`, `<-[e:CALLS]-`, `-[:CALLS]-` or `<-[:CALLS]->` for either way, `-[]->` or `->`, `<-`, `-` (Cypher `-->`, `<--`, `--`) for any edge label, `-[:A\|B]->`), `WHERE` conditions, `RETURN [DISTINCT] ... [ORDER BY k [ASC\|DESC], ...] [OFFSET n \| SKIP n] [LIMIT n]` |
//! | Edges | an edge is a pair of nodes of its label's relation: either way reads it both ways (a relation of two rules), several labels (or none: every edge label) their union, so a pair joined by two labels matches once; an edge variable's properties (`e.weight`, [`Catalog::edge_property`]: (from, to, value) rows; [`Catalog::typed_edge_property`]: signed, float, boolean or string values, a null value null, `IS [NOT] NULL` read on it) are values in `WHERE`, `RETURN`, `ORDER BY` and aggregates; an edge variable in `RETURN` is a whole edge (below); an edge variable in a comparison, and a property of a quantified edge outside an edge predicate (the Edge predicates row), are refused |
//! | Aggregates | `count(*)`, `count(x)`, `count(DISTINCT x)`, `min(x)`, `max(x)` (`x` a node or a property) per group: the rows equal on every item that is not an aggregate (none: one row; counts over no match are 0). `count(*)` and `count(x)` count matches (the Rows row): a counting rule ([`kleene_plan::Plan::count_rule`]) over the counted matches, never their rows; min and max are [`kleene_plan::Aggregate`] rules over the match, joined on the groups. `sum(x)` and `avg(x)` (a float) are [`kleene_plan::Fold`]s weighed by each match's count ([`kleene_plan::Fold::times`]); `sum(DISTINCT x)`, `avg(DISTINCT x)` and `count(DISTINCT x)` over the distinct values. `ORDER BY` names a returned column. A value that may be null (a typed property of a node or an edge, arithmetic) is skipped where null: `count(x)` counts the rows where it is not null (0 for a group with none); `min`, `max`, `sum`, `avg` of a group with none are null |
//! | Rank | `rank(x BY g, ..)` in `RETURN` (not a standard GQL function; no window functions there): per row, the number of distinct values of `x` before its own among the rows equal on the `g`s, rising, from 0 (equal values share it; without `BY` all rows are one group); every row is kept, a row per match with its count. Lowered onto the core's [`kleene_plan::Aggregate::rank`] over the match relation, one rule per rank item; `ORDER BY` may name its column. A row whose `x` is null is not returned. Refused: beside an aggregate in one `RETURN` (rank after a `WITH`), with OPTIONAL MATCH, beside `nodes(p)`, of or by a constant |
//! | Paths | `p = (a)-[:T]->(b)...` over fixed edges: `nodes(p)` (or `p`) the nodes in pattern order, `length(p)` the number of edges. `p = ANY SHORTEST (a)-[:T]->+(b)` (Cypher `shortestPath((a)-[:T*]->(b))`; `ANY`, a `WALK` mode and `PATH`/`PATHS` accepted) keeps one shortest path per (a, b), `ALL SHORTEST` (`allShortestPaths`) every shortest path, a row each: [`kleene_plan::Plan::shortest`], one BFS per start on kleene-graph, a path's vertices read back through its parents (ANY: the lowest vertex at each step back from the end). The pattern is one edge pattern, quantified `*`, `+`, `{0,n}`, `{1,n}` (or one edge); with `+` a start is an end only through a cycle. A list column holds an index into [`Table::lists`] ([`Table::list`]). Refused: a path variable over a quantified edge with no selector (infinitely many walks), a selector over more than one edge pattern or a range from 2, `TRAIL`/`SIMPLE`/`ACYCLIC`, `SHORTEST k`, `ANY k`, `ALL` with no `SHORTEST`, a list in `ORDER BY` or with aggregates, a path in `WHERE` |
//! | Procedures | `CALL name(EdgeLabel, ...) [YIELD column [AS v], ...] [WHERE ...]` first, then `MATCH` clauses on the yielded variables, then `RETURN` (a `CALL` alone returns every column). Each is [`kleene_plan::Plan::procedure`], one kleene-graph kernel on the label's edges (vertices `0..n`); names case-blind, with or without `algo.`/`gds.`/`kleene.` and `.stream`: `pagerank` (`pageRank`; node, score), `wcc` (`weaklyConnectedComponents`, `connectedComponents`, `components`; node, component = least vertex), `scc` (`stronglyConnectedComponents`; node, component), `sssp(E, source [, weightKey])` (`dijkstra`, `deltaStepping`; node, distance, reached nodes only; weights from an edge property), `bfs(E, source)` (every edge 1), `betweenness` (`betweennessCentrality`, `bc`; node, score, every vertex a source), `triangleCount` (`triangles`, `tc`; count, the edges both ways), `harmonic(E [, auto | exact | estimate [, log2Registers]])` (`harmonicCentrality`, `closeness.harmonic`; node, score: the sum of 1 / hops over the nodes it reaches; `auto`, the default, is exact up to 65536 vertices and HyperBall with 2^7 registers above; `estimate` takes 2^4 to 2^16 registers), `ktruss(E, k)` (`truss`; source, target, support: each edge of the k-truss once, source below target, the edges both ways, self-loops left out; source and target are nodes), `trussNumbers(E)` (`trussNumber`, `truss_numbers`, `trussDecomposition`; source, target, truss: every edge once, source below target, with the largest k whose k-truss holds it, 2 in no triangle), `mis(E [, seed])` (`maximalIndependentSet`, `independentSet`; node: a maximal independent set of the edges both ways, self-loops left out, fixed by the seed, 0 when none is given), `msf(E [, weightKey])` (`mst`, `spanningForest`, `minimumSpanningForest`, `spanningTree`, `minimumSpanningTree`; source, target, weight for each edge of a minimum spanning forest, the edges both ways, the weight of its property's type (unsigned, signed or float); `sum(weight)` over them is the total), `maxflow(E, source, target [, capacityKey])` (`maxFlow`, `maximumFlow`; flow: one row, the value of a maximum flow, each edge of capacity 1 or its property, repeats summed; a float property gives a float flow). PageRank, betweenness, triangles, harmonic centrality, the k-truss, the truss numbers, the independent set, the spanning forest and the maximum flow run on the CPU backend. Scores are floats ([`Table::float_columns`], [`Table::float`]), compared with number literals as floats (`WHERE score > 0.1`) |
//! | State machine | `CALL machine.steps(Edge, labelKey, Eps, Start) YIELD state, label, next`, `CALL machine.states(..) YIELD state, node`, `CALL machine.starts(..) YIELD node, state`: the subset construction over the `Edge` edges, each step named by the edge's `labelKey` property (of any type), with the closure through the `Eps` edges (`NULL`: none), from the nodes of label `Start`, each its own start; a state is a set of nodes closed under `Eps`, numbered from 0. After `Start`, optional: a property name of the start nodes as their key (equal values make one start set; `machine.starts` then yields `key, state`) and an integer, the limit of states (default 1000000); over it the run stops with the core's `SetLimit` (``plan: sets `machine.member`: more than 3 sets``). All three calls are one core helper ([`kleene_plan::Plan::state_machine`], the same rules a Datalog program writes with `sets` and `N = set(..) in ..`), so their numbers agree, on every run and at every thread count; `node` binds a node later patterns match, the rest are values. `Edge` and `Eps` go within one node label and `Start` is a label of its nodes; edges over two labels are refused by name |
//! | Schema | `CALL schema.labels() YIELD label`, `CALL schema.edges() YIELD edge`, `CALL schema.columns() YIELD label, column, type`, `CALL schema.refused() YIELD label, column, why`: the set's node labels (one with no nodes too), edge labels, the columns the catalog reads (type `u64`, `i64`, `f64`, `bool` or `str`) and those it refuses with why, as strings: the core's schema relations ([`kleene_plan::Plan::schema`], filled by [`kleene_plan::Inputs::bind_schema`]), the same a Datalog program's rules read. A node label the set lacks in a pattern (`MATCH (n:Missing)`) is refused by name |
//! | Conditions | [`Condition`]: comparisons (`=`, `<>`, `<`, `<=`, `>`, `>=`) of node ids, properties, unsigned integers and parameters, `IN (v, ...)` / `IN [v, ...]` (of a node or a node's property, every `v` a constant or parameter: the core's list test, `kleene_plan::Cond::OneOf`, as `datalog!`'s `K in (..)`, one rule however long the list, a lookup per value on an indexed property; a `NULL` in the list is dropped, so `IN` is then true or unknown and `NOT ... IN` never true; any other `IN` an OR of equalities), `NOT`, `AND`, `OR`, `XOR`, brackets; GQL's three-valued logic (a comparison of a missing property is unknown; only true keeps a match). Comparisons at the top of a `WHERE` join the match rule (a node's own ones seed its walks); any other part becomes relations of the bindings where each sub-condition is true and where it is false, a few rules per sub-condition (never a disjunctive form, which can grow exponentially). `hex(n.k)` (or of an edge, `hex(e.k)`) is property `k` as the lowercase hex of its bytes, a string value wherever a property is one: the catalog's relation `L.k@hex` ([`Catalog::relation`]), for bytes that are not text such as hashes; `n.k` of a bytes column is its text |
//! | Paths | a quantified edge: GQL `-[:T]->*` (0 or more), `-[:T]->+` (1 or more), `{m,n}`, `{m,}`, `{,n}`, `{n}`; the Cypher forms `-[:T*]->` (1 or more), `*m..n`, `*..n`, `*n` are read too. 0 or 1 to no bound runs as a reach (BFS) or closure; any other range as a walk ([`kleene_plan::Plan::walk`]: frontier steps with nothing visited) |
//! | Path semantics | GQL's WALK mode: `(a)-[:T]->{m,n}(b)` holds when some walk from `a` to `b` of `m` to `n` edges exists (vertices and edges may repeat); with a bounded length a row per walk (the Rows row), under `DISTINCT` or [`kleene_plan::Rows::Distinct`] that pair once however many walks join it. So `{3}` on a cycle of three comes back to the start, and `{1,k}` ends at the vertices within `k` edges of the start (the start too when a cycle of at most `k` edges holds it): with the start left out (`WHERE b <> $s`) that is the k-hop answer of `kleene puppygraph` (a search of `k` levels, the source not counted), checked equal in `kleene`'s tests |
//! | Names | [`Catalog`]: node label, edge label, node property and edge property names, each a relation's source ([`kleene_plan::Source`]); a property of a node with label alternatives is read from those of its labels that have it. An unsigned (`u64`) property with no value, null in its column or a null element of its list, gives no row where it is read, in `WHERE`, `RETURN` and `UNWIND`. This differs from the GQL standard, where the row stays with a NULL; a property of any other type keeps the row with a NULL |
//! | Plan | [`lower`]: the query as a [`kleene_plan::Plan`] ([`Lowered`]); a quantified edge as a reach (BFS) or closure on the graph core, never recursive joins; the rest as one match rule ([`lower`] gives the rules) |
//! | Optional | `MATCH ... OPTIONAL MATCH pattern [WHERE ...] [OPTIONAL MATCH ...]`: each clause extends the rows so far, each with every extension by its pattern and condition, or once with its new values null ([`Table::nulls`], [`Table::is_null`]; `Datum::Null` in [`Lowered::run_typed`]); a clause that reads a value of an earlier one that is null does not match. A condition there on a node before it only decides the extension. Nulls sort last rising and first falling; `count(x)` counts the rows where `x` is found (0 for none), `count(*)` every row; `min`/`max`/`sum`/`avg` of its values skip the nulls and are null for a group with none. Lowered as `pre` (the matches before), then per clause `full{j}` (extended), a negation of `found{j}` and `opt{j}` (the rows so far with a found flag). Refused: a `MATCH` after an OPTIONAL MATCH, OPTIONAL MATCH first, one of its values as a group key, `OR`/`NOT`/`XOR`/`IN` over several nodes, `nodes(p)` |
//! | With | `... WITH [DISTINCT] item [AS name], ... [ORDER BY ...] [SKIP n] [LIMIT n] [WHERE ...]` then the next part (`MATCH`, `OPTIONAL MATCH`, `UNWIND`, `CALL { }`, `WITH`, `RETURN`): the part before runs first ([`Lowered::run_typed`], its own ORDER BY / LIMIT / aggregates) and its rows fill an input relation of the next part's plan whose columns the names bind: a node as a node (with its labels), a path as its length, any other value typed (an unsigned value that may be null as a signed one). Without DISTINCT or an aggregate, the nodes the WITH leaves out go on as hidden columns, so each match stays a row of its own. `shortestPath(...) AS p` / `allShortestPaths(...) AS p` as an item is the path of an OPTIONAL MATCH before it (null where none leads). A row per row before (a counted input: each distinct row with its number). Refused: a path's nodes after a WITH (its length only), a null node passed on |
//! | Subqueries | `CALL { [WITH a, ...] MATCH ... RETURN ... }` after a part: the part's rows (every name it binds) feed the subquery, whose rows carry its returned columns and the outer names on to the rest of the query (two WITH boundaries); a subquery of aggregates alone is one row per outer row (its one MATCH read as OPTIONAL: a count of none is 0). Refused: `ORDER BY`, `SKIP`, `LIMIT` inside it (per outer row), a subquery that returns nothing, `CALL { }` first |
//! | Unwind and arithmetic | `UNWIND [v, ...] AS x` (constants, or expressions over bound values), `UNWIND $list AS x` ([`Param::List`]), `UNWIND n.key AS x` of a list property of a node bound before or of an edge `e` of the `MATCH` just before (`UNWIND e.key AS x`, with a direction; [`Catalog::list_property`], [`Catalog::list_edge_property`]: one item per element, equal elements each a row, an empty or null list none): each row (the part before, or one row) once per item, a rule per item; unsigned and signed items together as signed, other mixes refused. Arithmetic `+ - * / %` (`* / %` first, brackets), unary `-x`, and the bit functions `bitand(a, b)`, `bitor`, `bitxor`, `bitnot(a)`, `shiftleft(a, n)`, `shiftright(a, n)` (integers only) in `WHERE`, `RETURN` and `UNWIND`: a computed value of the rule ([`kleene_plan::Compute`], one per operator), integers as `i64` (a float side: `f64`), null for a null side, a division by zero, an overflow or a shift outside `0..64` (a comparison with it then not true). Strings: `a || b`, `char_length(s)` / `character_length(s)` (characters, `i64`), `substring(s, start [, len])` (from 0, past the end shorter), computed values of the rule over [`kleene_plan::Func`], null for a null argument or a negative place or length. A bracket at the start of a condition is read as a bracketed condition |
//! | Comparisons of values | Both sides of a comparison may be properties of two nodes (`a.age = b.age`, `a.id < b.id`; a null side is not true), arithmetic, ids or lengths. List predicates over a path's edges: the row below |
//! | Edge predicates | Over the edges of a quantified edge `-[r:T*m..n]->` (`+`, `*`, `{m,n}`), at the top of its MATCH's WHERE: `all(x IN r WHERE c)`, the short form `r.key op v` (every edge), and `none(x IN r WHERE c)` filter the edges before the walk (a relation of the edges where `c` is true, or false, the walk or closure runs over it alone, `--explain`: `the walk keeps the edges where ...`), so the search never steps on another edge; `any(...)` and `single(...)` cannot filter first: over `*` or `+` (no upper bound) the pattern is read as `-[*0..]->()-[x]->()-[*0..]->` with `x` an edge that passes (for `single`, the other edges failing `c`), the middle nodes no columns, so a pair of ends is one row. `c` is a comparison of the edge's properties (typed, nulls never passing) with constants or parameters, or an AND of them. Answers are per pair of ends (WALK mode): a walk may repeat an edge. Refused by name: `any` / `single` over a bounded length, another `c`, a list predicate inside OR / NOT |
//! | Union | `query UNION query` (the distinct rows, sorted; a null and a 0 apart) and `UNION ALL` (each part's rows in turn), the parts returning the same column names. Refused: `UNION` and `UNION ALL` mixed, `ORDER BY`, `OFFSET` or `LIMIT` in a part, a returned list, `UNION` (not `ALL`) in [`Lowered::run_typed`] |
//! | Indexes | [`Catalog::property_index`]: a node of one label with constant bounds on an indexed unsigned property (`=`, `<`, `<=`, `>`, `>=`, in the WHERE's top `AND`; an equality preferred) is found by one range lookup instead of a scan of the label. An OR of equalities of one such property with constants (`u.id = $a OR u.id = $b`, with no bound in the `AND`) is one lookup per value (`--explain`: `index lookup L.key at a, b`), the OR still checked on the rows. [`Catalog::reach_index`]: `-[:T]->*` (and `+`, as one edge then a reach) between ends each pinned (equal to a constant, or found by a lookup) is answered by the index, no search; either way, label alternatives and bounded lengths are not. Signed and float properties go through the range index on their order-keeping codes (the null code, the largest, is never in a range); a string range does not (run-dictionary ids keep no order). [`Catalog::name_index`] ([`NameIndex`]): `n.key = "text"`, `IN` a list of strings or a property map `(n:L {key: "text"})` on a string property is one lookup per string (preferred over a range). [`Catalog::kinds_index`] / [`Catalog::kind_label`]: a label set of kinds of one index (`(n:A)`, `(n:A|B)`) is one lookup per kind, a union of the bitmaps. A node with no label in a catalog of one id space (any node, or at an edge) is found by the range or name index of every label holding the key, a lookup each (`index lookup A|B.key in lo..=hi`), when each has one. Other nodes are label scans. [`Lowered::explain`] (`kleene gql --explain`) lists the choice per node and edge, then the strata |
//! | Ids | `id(n)` in `WHERE`, `RETURN` and `ORDER BY`. In a catalog of vertex tables ([`Catalog::vertex_table`]: a label whose nodes are rows `0..count`, numbered from a base) a node's value is its row and `id(n)` is base + row, the tables numbered one after the other (`kleene gql`: the set's vertex types in order, each from the sum of the counts before it), so two tables' ids never collide; a label of some of a table's rows takes the table's base ([`Catalog::id_base`]); a node with no label at an edge end is a row of the table that end names ([`Catalog::edge_ends`]). In a catalog with no vertex tables (one id space) `id(n)` is the node itself. `id(n) = c` and bounds `id(n) >= a AND id(n) < b` in the WHERE's top `AND` list the rows in the range from the numbers alone (no label scan, no index; `explain`: `id range`). In one id space the same holds where the labels are blocks of ids ([`Catalog::id_block`]: `kleene gql` gives each vertex type's), for an equality, bounds or an OR of equalities (`id(n) = $a OR id(n) = $b`), with no label, any label or labels that are blocks: the core's [`kleene_plan::IdRanges`] lists the ids, no label read. Refused by name: `id(r)` of an edge (an edge is a pair of nodes here, with no id of its own), `id(n)` of a node with no label whose edges name no table |
//! | Two tables | A catalog of one id space (every node by its id, as kleene-gar's `IdSpace` numbers a set's vertex types and `kleene gql` reads a set) joins nodes of two types as they are: either way, unions of edge labels, walks, label alternatives, comparisons and `UNION` need nothing more. In a catalog of vertex tables ([`Catalog::vertex_table`]), where a node is its row and rows of two tables share their numbers, a match where nodes of two tables meet is refused by name: a node of labels of two tables, a node of any table at an edge, an edge whose (label, way) pairs join two pairs of tables or a table its end does not have, a variable-length edge through two tables, two nodes of two tables compared, a `UNION` column of nodes of two tables |
//! | No label | `MATCH (n)`, `MATCH (n {key: v})`, `MATCH (n) WHERE ...` with no label and no edge: any row of any vertex table, bound by its `id(n)` (in a catalog of one id space: any node of any label, each once); a property is read from each table that has it (one rule each; a node of a table without it has no value, so a comparison of it is not true), of one type on all of them or refused. [`Catalog::sub_label`] (a kind label of a vertex type): a label of some of another label's nodes has that label's properties (one relation for both), `labels(n)` of a node found by the other label lists it where it holds the node, and a node of any label is a node of a label of no other's (no scan of the kind labels) |
//! | Whole values | `RETURN n` is the whole node, `RETURN r` the whole edge ([`Entity`], in [`Table::entities`] / [`TypedTable::entities`], [`Table::entity`]; printed by the tables' `Display`, so `kleene gql` prints them): a node's `id(n)`, its labels and every property of them by name, typed, a missing or null value null; an edge's label, the `id(n)` of its ends as stored (from, to) and its properties. `labels(n)`, `type(r)`, `properties(n)`, `properties(r)` give a part; `relationships(p)` the edges of a path in order (a fixed path's, a shortest path's as walked); `nodes(p)` the `id(n)` of its nodes (a list). The cell of such a column keeps the match's value (a node's value, an edge's from node) for ordering and `DISTINCT`. Read after `ORDER BY` / `SKIP` / `LIMIT` cut the rows, by a second small plan over the returned values only (each label's membership and properties, each edge label's pairs and properties): `RETURN n LIMIT 1` reads one node. A node of a vertex table has its table's label (and, found by a label of some of the table's rows such as a kind label, that one too); in a catalog of one id space every label holding the node is listed, the properties of the first holding a key. The label of an edge of several labels is the first (by name) holding the pair; an edge property of several edges between one pair is the least. A procedure's node and a node passed on by a `WITH` are whole too. With `UNION` a whole value is one by all of it (two edges from one node are two rows); with aggregates a whole node, edge or path is a group key (one group per node, edge, path) and `count(r)` / `count(DISTINCT r)` count an edge per match / once; with OPTIONAL MATCH a whole value is null where the clause finds none (an edge by an end of its own clause). In a catalog of vertex tables a node with no label whose table is not known (a procedure's) comes back as its value alone. Refused by name: `labels(n)`, `type(r)`, `properties(x)` with aggregates (a group is a node or edge here, not a value of one); an OPTIONAL MATCH edge between two nodes bound before it as a value; `relationships(p)` with OPTIONAL MATCH; a quantified edge as a value; anything but a node passed on by a `WITH` |
//! | Parameters | `$name` where a value goes; [`lower_with`] / [`query_with`] take their values ([`Params`]); one with no value is refused |
//! | Order | `ORDER BY` keys ([`OrderKey`]): a returned column by its name (alias, `var`, `var.key`) or, without `DISTINCT`, any variable or property of the match; rows equal on every key by their values, rising; no keys: by their values. `OFFSET`/`SKIP` then `LIMIT` cut the ordered rows, the same rows on every run |
//! | Run | [`Lowered::run`] / [`query`] on a [`kleene_plan::Engine`]: a [`Table`] of rows in order, printed as text by its `Display` |
//! | Rows | One row per match, Cypher's and ISO GQL's default: a match binds every node and edge of the pattern, the anonymous ones too (`(s)-->()-->(n)`: one per middle node and per pair of edges), so `RETURN n.id` without `DISTINCT` returns a row per match, `count(*)` / `count(x)` count matches and `sum` / `avg` weigh by them. The matches are a counted relation ([`kleene_plan::Plan::derived_counted`]: one row per distinct binding with its number of matches), expanded into rows only at the output ([`kleene_plan::Output::rows_as`]), never under a count. A bounded length (`*5..5`, `*1..3`, `{m,n}`) counts its walks per pair of ends, one plus-times step per edge ([`kleene_plan::Plan::walk_counted`]): `MATCH (s {id: $id})-[:T*6..6]->(t) RETURN count(t)` is six steps from one start, no walk listed. Parallel edges are matches of their own where the catalog has their counts ([`Catalog::edge_counts`]: (source, destination, number)); without, a pair of nodes is one edge (an edge is a pair here). An edge variable whose properties are read (`MATCH (a)-[r:E]->(b) RETURN r.p, r.q`) is read by its rows where the catalog has them for each of its labels (`E@row`, `E@row.p`: [`Catalog::edge_rows`]): each edge is then a match of its own with its own values (one label, label alternatives, either way; not a quantified edge). `RETURN DISTINCT`, `count(DISTINCT x)` and [`kleene_plan::Rows::Distinct`] for a whole query ([`lower_rows`], `kleene gql --distinct-rows`) give each distinct row once. NOT the standard yet: (1) Cypher matches an edge at most once per match (GQL: `DIFFERENT EDGES`), here an edge may be used twice in one match, in a fixed pattern or a walk: on one self loop `a -> a`, `MATCH (x)-->(y)-->(z) RETURN count(*)` is 1 here and 0 in Cypher (the two steps take the same edge), and `-[*2..2]->` counts 1 walk where Cypher has none; nothing flags it, the counts are WALK mode's. (2) An unbounded length (`*`, `+`, `{m,}`) is one row per pair of ends (reachability: the number of walks is not finite on a cycle). An edge either way (`-[]-`) or of label alternatives (`-[:A|B]->`, `-->`) is a match per label and per way it is read (a pair by `A` and by `B` two matches, a self loop either way one), each label's parallel edges counted, in a fixed step and a walk of bounded length; two names of one edge label ([`Catalog::edge_alias`]) are read once |
//! | Command line | `kleene gql "<query>" <X.gar> [--param name=value] [--explain] [--distinct-rows]` (the umbrella crate, feature `gql`, on by default): vertex types as node labels, edge types as edge labels (`src_edge_dst`, or the edge name alone when unique), vertex columns as properties by their Arrow type (unsigned as values; signed, float, boolean and string typed, a null slot null; another type refused by name where read, [`Catalog::refused_property`]); unsigned, signed and float columns indexed (sorted at the first lookup), each edge type a reach index (kleene-index's 2-hop labels, built at the first lookup); returned values printed by type when [`Lowered::returns_typed`] |
//!
//! No engine code is here: the query is lowered onto kleene-plan, which plans and runs it
//! the same way it runs the Datalog client's rules.
//!
//! The parser started from the parked openCypher parser (branch `parked/kq-cypher`), cut to
//! the subset above and moved to GQL's syntax where the two differ: `IS` for labels,
//! quantifiers after the edge pattern, `<>` for "not equal".

mod ast;
mod error;
mod lexer;
mod lower;
mod parser;
mod whole;

pub use ast::{
    AggFn, BinOp, CallArg, CallClause, CmpOp, Comparison, Condition, Dir, EdgePattern, Float,
    ListQuant, Match, NodePattern, Operand, OrderKey, PathPattern, Quantifier, Query, Return,
    ReturnItem, ReturnValue, Selector, TextOp, Unwind, UnwindList, WholeFn, YieldItem,
};
pub use error::{GqlError, Result};
pub use kleene_plan::{Catalog, NameIndex};
pub use lower::{
    Lowered, Param, Params, Table, TypedTable, lower, lower_rows, lower_with, query, query_with,
};
pub use parser::parse;
pub use whole::Entity;

/// The README's example, run as a doctest.
#[cfg(doctest)]
#[doc = include_str!("../README.md")]
struct ReadmeDoctests;