Skip to content

Commit 194ae5e

Browse files
committed
rename cascades_group to group
1 parent ce1b93d commit 194ae5e

20 files changed

+137
-122
lines changed

optd-mvp/DESIGN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ of a problem.
5858

5959
TODO explain the fingerprinting algorithm and how it relates to group merging
6060

61+
Union find data structure with a circular linked list for linear iteration
62+
6163
When taking the fingerprint of an expression, the child groups of an expression need to be root groups. If they are not, we need to try again.
6264
Assuming that all children are root groups, the fingerprint we make for any expression that fulfills that is valid and can be looked up for duplicates.
6365
In order to maintain that correctness, on a merge of two sets, the smaller one requires that a new fingerprint be generated for every expression that has a group in that smaller set.

optd-mvp/src/entities/cascades_group.rs renamed to optd-mvp/src/entities/group.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,35 @@
33
use sea_orm::entity::prelude::*;
44

55
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
6-
#[sea_orm(table_name = "cascades_group")]
6+
#[sea_orm(table_name = "group")]
77
pub struct Model {
88
#[sea_orm(primary_key)]
99
pub id: i32,
1010
pub status: i8,
1111
pub winner: Option<i32>,
1212
pub cost: Option<i64>,
1313
pub parent_id: Option<i32>,
14+
pub next_id: Option<i32>,
1415
}
1516

1617
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
1718
pub enum Relation {
19+
#[sea_orm(
20+
belongs_to = "Entity",
21+
from = "Column::NextId",
22+
to = "Column::Id",
23+
on_update = "Cascade",
24+
on_delete = "SetNull"
25+
)]
26+
SelfRef2,
1827
#[sea_orm(
1928
belongs_to = "Entity",
2029
from = "Column::ParentId",
2130
to = "Column::Id",
2231
on_update = "Cascade",
2332
on_delete = "SetNull"
2433
)]
25-
SelfRef,
34+
SelfRef1,
2635
#[sea_orm(has_many = "super::logical_children::Entity")]
2736
LogicalChildren,
2837
#[sea_orm(has_many = "super::logical_expression::Entity")]
@@ -56,7 +65,7 @@ impl Related<super::logical_expression::Entity> for Entity {
5665
super::logical_children::Relation::LogicalExpression.def()
5766
}
5867
fn via() -> Option<RelationDef> {
59-
Some(super::logical_children::Relation::CascadesGroup.def().rev())
68+
Some(super::logical_children::Relation::Group.def().rev())
6069
}
6170
}
6271

@@ -65,11 +74,7 @@ impl Related<super::physical_expression::Entity> for Entity {
6574
super::physical_children::Relation::PhysicalExpression.def()
6675
}
6776
fn via() -> Option<RelationDef> {
68-
Some(
69-
super::physical_children::Relation::CascadesGroup
70-
.def()
71-
.rev(),
72-
)
77+
Some(super::physical_children::Relation::Group.def().rev())
7378
}
7479
}
7580

optd-mvp/src/entities/logical_children.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ pub struct Model {
1414
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
1515
pub enum Relation {
1616
#[sea_orm(
17-
belongs_to = "super::cascades_group::Entity",
17+
belongs_to = "super::group::Entity",
1818
from = "Column::GroupId",
19-
to = "super::cascades_group::Column::Id",
19+
to = "super::group::Column::Id",
2020
on_update = "Cascade",
2121
on_delete = "Cascade"
2222
)]
23-
CascadesGroup,
23+
Group,
2424
#[sea_orm(
2525
belongs_to = "super::logical_expression::Entity",
2626
from = "Column::LogicalExpressionId",
@@ -31,9 +31,9 @@ pub enum Relation {
3131
LogicalExpression,
3232
}
3333

34-
impl Related<super::cascades_group::Entity> for Entity {
34+
impl Related<super::group::Entity> for Entity {
3535
fn to() -> RelationDef {
36-
Relation::CascadesGroup.def()
36+
Relation::Group.def()
3737
}
3838
}
3939

optd-mvp/src/entities/logical_expression.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ pub struct Model {
1414

1515
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
1616
pub enum Relation {
17+
#[sea_orm(has_many = "super::fingerprint::Entity")]
18+
Fingerprint,
1719
#[sea_orm(
18-
belongs_to = "super::cascades_group::Entity",
20+
belongs_to = "super::group::Entity",
1921
from = "Column::GroupId",
20-
to = "super::cascades_group::Column::Id",
22+
to = "super::group::Column::Id",
2123
on_update = "Cascade",
2224
on_delete = "Cascade"
2325
)]
24-
CascadesGroup,
25-
#[sea_orm(has_many = "super::fingerprint::Entity")]
26-
Fingerprint,
26+
Group,
2727
#[sea_orm(has_many = "super::logical_children::Entity")]
2828
LogicalChildren,
2929
}
@@ -40,9 +40,9 @@ impl Related<super::logical_children::Entity> for Entity {
4040
}
4141
}
4242

43-
impl Related<super::cascades_group::Entity> for Entity {
43+
impl Related<super::group::Entity> for Entity {
4444
fn to() -> RelationDef {
45-
super::logical_children::Relation::CascadesGroup.def()
45+
super::logical_children::Relation::Group.def()
4646
}
4747
fn via() -> Option<RelationDef> {
4848
Some(

optd-mvp/src/entities/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
pub mod prelude;
44

5-
pub mod cascades_group;
65
pub mod fingerprint;
6+
pub mod group;
77
pub mod logical_children;
88
pub mod logical_expression;
99
pub mod physical_children;

optd-mvp/src/entities/physical_children.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ pub struct Model {
1414
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
1515
pub enum Relation {
1616
#[sea_orm(
17-
belongs_to = "super::cascades_group::Entity",
17+
belongs_to = "super::group::Entity",
1818
from = "Column::GroupId",
19-
to = "super::cascades_group::Column::Id",
19+
to = "super::group::Column::Id",
2020
on_update = "Cascade",
2121
on_delete = "Cascade"
2222
)]
23-
CascadesGroup,
23+
Group,
2424
#[sea_orm(
2525
belongs_to = "super::physical_expression::Entity",
2626
from = "Column::PhysicalExpressionId",
@@ -31,9 +31,9 @@ pub enum Relation {
3131
PhysicalExpression,
3232
}
3333

34-
impl Related<super::cascades_group::Entity> for Entity {
34+
impl Related<super::group::Entity> for Entity {
3535
fn to() -> RelationDef {
36-
Relation::CascadesGroup.def()
36+
Relation::Group.def()
3737
}
3838
}
3939

optd-mvp/src/entities/physical_expression.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ pub struct Model {
1515
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
1616
pub enum Relation {
1717
#[sea_orm(
18-
belongs_to = "super::cascades_group::Entity",
18+
belongs_to = "super::group::Entity",
1919
from = "Column::GroupId",
20-
to = "super::cascades_group::Column::Id",
20+
to = "super::group::Column::Id",
2121
on_update = "Cascade",
2222
on_delete = "Cascade"
2323
)]
24-
CascadesGroup,
24+
Group,
2525
#[sea_orm(has_many = "super::physical_children::Entity")]
2626
PhysicalChildren,
2727
}
@@ -32,9 +32,9 @@ impl Related<super::physical_children::Entity> for Entity {
3232
}
3333
}
3434

35-
impl Related<super::cascades_group::Entity> for Entity {
35+
impl Related<super::group::Entity> for Entity {
3636
fn to() -> RelationDef {
37-
super::physical_children::Relation::CascadesGroup.def()
37+
super::physical_children::Relation::Group.def()
3838
}
3939
fn via() -> Option<RelationDef> {
4040
Some(

optd-mvp/src/entities/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
#![allow(unused_imports)]
44

5-
pub use super::cascades_group::Entity as CascadesGroup;
65
pub use super::fingerprint::Entity as Fingerprint;
6+
pub use super::group::Entity as Group;
77
pub use super::logical_children::Entity as LogicalChildren;
88
pub use super::logical_expression::Entity as LogicalExpression;
99
pub use super::physical_children::Entity as PhysicalChildren;

optd-mvp/src/expression/logical_expression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Definition of logical expressions / relations in the Cascades query optimization framework.
1+
//! Definition of logical expressions / relations in our query optimization framework.
22
//!
33
//! FIXME: All fields are placeholders.
44
//!

optd-mvp/src/expression/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! In-memory representation of Cascades logical and physical expression / operators / relations.
1+
//! In-memory representation of logical and physical expression / operators / relations.
22
//!
33
//! TODO more docs.
44
@@ -8,7 +8,7 @@ pub use logical_expression::*;
88
mod physical_expression;
99
pub use physical_expression::*;
1010

11-
/// The representation of a Cascades expression.
11+
/// The representation of an expression.
1212
///
1313
/// TODO more docs.
1414
#[derive(Clone, Debug)]

0 commit comments

Comments
 (0)