diff --git a/crates/query-ops/docs/diagrams/architecture.dot b/crates/query-ops/docs/diagrams/architecture.dot index 62eb353..a073ed4 100644 --- a/crates/query-ops/docs/diagrams/architecture.dot +++ b/crates/query-ops/docs/diagrams/architecture.dot @@ -31,15 +31,20 @@ style = "dashed" color = "#888888" fontcolor = "#555555" margin = 18 -edge_table [label = < - +author_table [label = <
Table: edge
+ - +
Table: author
• arity 2
• rows: (src, dst)
• rows: (name, book)
>, fillcolor = "#E8F4FD", color = "#2196F3"] -labeled_table [label = < - +bestseller_table [label = <
Table: labeled
+ - + +
Table: bestseller
• arity 1
• rows: (node)
• rows: (book)
>, fillcolor = "#E8F4FD", color = "#2196F3"] +price_table [label = < + + +
Table: price
• arity 2
• rows: (book, dollars)
>, fillcolor = "#E8F4FD", color = "#2196F3"] } @@ -49,27 +54,20 @@ style = "dashed" color = "#9C27B0" fontcolor = "#7B1FA2" margin = 14 -self_loops [label = < - - - - +author_rel [label = <
self_loops
pattern: [Var X, Var X]
filter: row[0] == row[1]
cols: [X]
+ + +
author_rel
pattern: [Var name, Var book]
cols: [name, book]
>, fillcolor = "#F3E5F5", color = "#9C27B0"] -edge_xy [label = < - - - - +bestseller_rel [label = <
edge_xy
pattern: [Var X, Var Y]
filter: none
cols: [X, Y]
+ + +
bestseller_rel
pattern: [Var book]
cols: [book]
>, fillcolor = "#F3E5F5", color = "#9C27B0"] -labeled_x [label = < - - - -
labeled_x
pattern: [Var X]
cols: [X]
>, fillcolor = "#F3E5F5", color = "#9C27B0"] -labeled_y [label = < - - - +price_rel [label = <
labeled_y
pattern: [Var Y]
cols: [Y]
+ + +
price_rel
pattern: [Var book, Var dollars]
cols: [book, dollars]
>, fillcolor = "#F3E5F5", color = "#9C27B0"] } @@ -79,53 +77,46 @@ style = "dashed" color = "#4CAF50" fontcolor = "#388E3C" margin = 14 -q1 [label = < - - - - +semijoin_step [label = <
Q1: semijoin
edge(X, X), labeled(X)
keep left rows whose [X] is in right
cols: [X]
+ + + +
semijoin
authors of bestsellers
shared: book
cols: [name, book]
>, fillcolor = "#E8F5E9", color = "#4CAF50"] -q2 [label = < - - - - +natural_join_step [label = <
Q2: natural_join
edge(X, Y), labeled(Y)
emit left ++ (right \ shared) per match
cols: [X, Y]
+ + + +
natural_join
attach each book's price
shared: book
cols: [name, book, dollars]
>, fillcolor = "#E8F5E9", color = "#4CAF50"] } -subgraph cluster_outputs { -label = "Outputs (binding relations)" +subgraph cluster_output { +label = "Output (binding relation)" style = "dashed" color = "#888888" fontcolor = "#555555" margin = 18 -q1_out [label = < - - - -
Q1 result
labeled self-loops
cols: [X]
>, fillcolor = "#ECEFF1", color = "#607D8B"] -q2_out [label = < - - - +result [label = <
Q2 result
edges into labeled nodes
cols: [X, Y]
+ + +
Q result
authors of bestsellers with each book's price
cols: [name, book, dollars]
>, fillcolor = "#ECEFF1", color = "#607D8B"] } // Atom scans consume tables -edge_table -> self_loops [color = "#2196F3"] -edge_table -> edge_xy [color = "#2196F3"] -labeled_table -> labeled_x [color = "#2196F3"] -labeled_table -> labeled_y [color = "#2196F3"] +author_table -> author_rel [color = "#2196F3"] +bestseller_table -> bestseller_rel [color = "#2196F3"] +price_table -> price_rel [color = "#2196F3"] -// Q1: edge(X, X), labeled(X) -> semijoin -self_loops -> q1 [label = "left", color = "#9C27B0"] -labeled_x -> q1 [label = "right", color = "#9C27B0"] +// semijoin narrows author_rel to bestseller authors +author_rel -> semijoin_step [label = "left", color = "#9C27B0"] +bestseller_rel -> semijoin_step [label = "right", color = "#9C27B0"] -// Q2: edge(X, Y), labeled(Y) -> natural_join -edge_xy -> q2 [label = "left", color = "#9C27B0"] -labeled_y -> q2 [label = "right", color = "#9C27B0"] +// natural_join attaches price +semijoin_step -> natural_join_step [label = "left", color = "#4CAF50"] +price_rel -> natural_join_step [label = "right", color = "#9C27B0"] -// Final outputs -q1 -> q1_out [color = "#4CAF50"] -q2 -> q2_out [color = "#4CAF50"] +// Final output +natural_join_step -> result [color = "#4CAF50"] } diff --git a/crates/query-ops/docs/diagrams/architecture.svg b/crates/query-ops/docs/diagrams/architecture.svg index 1d3a2be..f02b646 100644 --- a/crates/query-ops/docs/diagrams/architecture.svg +++ b/crates/query-ops/docs/diagrams/architecture.svg @@ -1,299 +1,159 @@ + "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> - - - QueryOpsHandPlan - - - cluster_inputs - - Inputs (positional tables) - - - - cluster_atoms - - Atom Scans  (scan_atom: Table × AtomPattern → Relation) - - - - cluster_joins - - Joins  (shared cols = matching column names) - - - - cluster_outputs - - Outputs (binding relations) - - - - - edge_table - - Table: edge - - • - arity 2 - - • - rows: (src, dst) - - - - - self_loops - - self_loops - - - pattern: [Var X, Var X] - - - filter: row[0] == row[1] - - - cols: [X] - - - - - edge_table->self_loops - - - - - - edge_xy - - edge_xy - - - pattern: [Var X, Var Y] - - - filter: none - - - cols: [X, Y] - - - - - edge_table->edge_xy - - - - - - labeled_table - - Table: labeled - - • - arity 1 - - • - rows: (node) - - - - - labeled_x - - labeled_x - - - pattern: [Var X] - - - cols: [X] - - - - - labeled_table->labeled_x - - - - - - labeled_y - - labeled_y - - - pattern: [Var Y] - - - cols: [Y] - - - - - labeled_table->labeled_y - - - - - - q1 - - Q1: semijoin - - - edge(X, X), labeled(X) - - - keep left rows whose [X] is in right - - - cols: [X] - - - - - self_loops->q1 - - - left - - - - - q2 - - Q2: natural_join - - - edge(X, Y), labeled(Y) - - - emit left ++ (right \ shared) per match - - - cols: [X, Y] - - - - - edge_xy->q2 - - - left - - - - - labeled_x->q1 - - - right - - - - - labeled_y->q2 - - - right - - - - - q1_out - - Q1 result - - labeled self-loops - - cols: [X] - - - - - q1->q1_out - - - - - - q2_out - - Q2 result - - - edges into labeled nodes - - - cols: [X, Y] - - - - - q2->q2_out - - - - + + +QueryOpsHandPlan + + +cluster_inputs + +Inputs (positional tables) + + +cluster_atoms + +Atom Scans  (scan_atom: Table × AtomPattern → Relation) + + +cluster_joins + +Joins  (shared cols = matching column names) + + +cluster_output + +Output (binding relation) + + + +author_table + +Table: author +• arity 2 +• rows: (name, book) + + + +author_rel + +author_rel +pattern: [Var name, Var book] +cols: [name, book] + + + +author_table->author_rel + + + + + +bestseller_table + +Table: bestseller +• arity 1 +• rows: (book) + + + +bestseller_rel + +bestseller_rel +pattern: [Var book] +cols: [book] + + + +bestseller_table->bestseller_rel + + + + + +price_table + +Table: price +• arity 2 +• rows: (book, dollars) + + + +price_rel + +price_rel +pattern: [Var book, Var dollars] +cols: [book, dollars] + + + +price_table->price_rel + + + + + +semijoin_step + +semijoin +authors of bestsellers +shared: book +cols: [name, book] + + + +author_rel->semijoin_step + + +left + + + +bestseller_rel->semijoin_step + + +right + + + +natural_join_step + +natural_join +attach each book's price +shared: book +cols: [name, book, dollars] + + + +price_rel->natural_join_step + + +right + + + +semijoin_step->natural_join_step + + +left + + + +result + +Q result +authors of bestsellers with each book's price +cols: [name, book, dollars] + + + +natural_join_step->result + + + +