Skip to content

Commit

Permalink
more type exercises
Browse files Browse the repository at this point in the history
Signed-off-by: Bugen Zhao <[email protected]>
  • Loading branch information
BugenZhao committed Oct 20, 2023
1 parent 36efecd commit 636d235
Show file tree
Hide file tree
Showing 44 changed files with 166 additions and 104 deletions.
1 change: 1 addition & 0 deletions src/frontend/src/optimizer/plan_node/batch_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use risingwave_common::error::Result;
use risingwave_pb::batch_plan::plan_node::NodeBody;
use risingwave_pb::batch_plan::LimitNode;

use super::generic::PhysicalPlanRef;
use super::utils::impl_distill_by_unit;
use super::{
generic, ExprRewritable, PlanBase, PlanRef, PlanTreeNodeUnary, ToBatchPb, ToDistributedBatch,
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/optimizer/plan_node/batch_over_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use risingwave_common::util::sort_util::{ColumnOrder, OrderType};
use risingwave_pb::batch_plan::plan_node::NodeBody;
use risingwave_pb::batch_plan::SortOverWindowNode;

use super::batch::BatchPlanRef;
use super::generic::PlanWindowFunction;
use super::utils::impl_distill_by_unit;
use super::{
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/optimizer/plan_node/batch_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use risingwave_pb::batch_plan::plan_node::NodeBody;
use risingwave_pb::batch_plan::ProjectNode;
use risingwave_pb::expr::ExprNode;

use super::generic::GenericPlanRef;
use super::utils::{childless_record, Distill};
use super::{
generic, ExprRewritable, PlanBase, PlanRef, PlanTreeNodeUnary, ToBatchPb, ToDistributedBatch,
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/src/optimizer/plan_node/batch_seq_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ use risingwave_pb::batch_plan::row_seq_scan_node::ChunkSize;
use risingwave_pb::batch_plan::{RowSeqScanNode, SysRowSeqScanNode};
use risingwave_pb::plan_common::PbColumnDesc;

use super::generic::GenericPlanRef;
use super::batch::BatchPlanRef;
use super::generic::{GenericPlanRef, PhysicalPlanRef};
use super::utils::{childless_record, Distill};
use super::{generic, ExprRewritable, PlanBase, PlanRef, ToBatchPb, ToDistributedBatch};
use crate::catalog::ColumnId;
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/optimizer/plan_node/batch_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use risingwave_common::error::Result;
use risingwave_pb::batch_plan::plan_node::NodeBody;
use risingwave_pb::batch_plan::SourceNode;

use super::generic::GenericPlanRef;
use super::utils::{childless_record, column_names_pretty, Distill};
use super::{
generic, ExprRewritable, PlanBase, PlanRef, ToBatchPb, ToDistributedBatch, ToLocalBatch,
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/optimizer/plan_node/batch_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use risingwave_common::error::Result;
use risingwave_pb::batch_plan::plan_node::NodeBody;
use risingwave_pb::batch_plan::UpdateNode;

use super::generic::GenericPlanRef;
use super::utils::impl_distill_by_unit;
use super::{
generic, ExprRewritable, PlanBase, PlanRef, PlanTreeNodeUnary, ToBatchPb, ToDistributedBatch,
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/src/optimizer/plan_node/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::hash::Hash;
use pretty_xmlish::XmlNode;
use risingwave_common::catalog::Schema;

use super::{stream, EqJoinPredicate};
use super::{stream, EqJoinPredicate, PlanNodeId};
use crate::optimizer::optimizer_context::OptimizerContextRef;
use crate::optimizer::property::{Distribution, FunctionalDependencySet};

Expand Down Expand Up @@ -85,6 +85,7 @@ macro_rules! impl_distill_unit_from_fields {
pub(super) use impl_distill_unit_from_fields;

pub trait GenericPlanRef: Eq + Hash {
fn id(&self) -> PlanNodeId;
fn schema(&self) -> &Schema;
fn stream_key(&self) -> Option<&[usize]>;
fn functional_dependency(&self) -> &FunctionalDependencySet;
Expand Down
4 changes: 3 additions & 1 deletion src/frontend/src/optimizer/plan_node/logical_apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ use risingwave_common::catalog::Schema;
use risingwave_common::error::{ErrorCode, Result, RwError};
use risingwave_pb::plan_common::JoinType;

use super::generic::{self, push_down_into_join, push_down_join_condition, GenericPlanNode};
use super::generic::{
self, push_down_into_join, push_down_join_condition, GenericPlanNode, GenericPlanRef,
};
use super::utils::{childless_record, Distill};
use super::{
ColPrunable, LogicalJoin, LogicalProject, PlanBase, PlanRef, PlanTreeNodeBinary,
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/optimizer/plan_node/logical_expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use itertools::Itertools;
use risingwave_common::error::Result;

use super::generic::GenericPlanRef;
use super::utils::impl_distill_by_unit;
use super::{
gen_filter_and_pushdown, generic, BatchExpand, ColPrunable, ExprRewritable, PlanBase, PlanRef,
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/optimizer/plan_node/logical_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use risingwave_common::bail;
use risingwave_common::error::Result;
use risingwave_common::types::DataType;

use super::generic::GenericPlanRef;
use super::utils::impl_distill_by_unit;
use super::{
generic, ColPrunable, ExprRewritable, LogicalProject, PlanBase, PlanRef, PlanTreeNodeUnary,
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/optimizer/plan_node/logical_hop_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use itertools::Itertools;
use risingwave_common::error::Result;
use risingwave_common::types::Interval;

use super::generic::GenericPlanNode;
use super::generic::{GenericPlanNode, GenericPlanRef};
use super::utils::impl_distill_by_unit;
use super::{
gen_filter_and_pushdown, generic, BatchHopWindow, ColPrunable, ExprRewritable, LogicalFilter,
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/optimizer/plan_node/logical_multi_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@ mod test {
use super::*;
use crate::expr::{FunctionCall, InputRef};
use crate::optimizer::optimizer_context::OptimizerContext;
use crate::optimizer::plan_node::generic::GenericPlanRef;
use crate::optimizer::plan_node::LogicalValues;
use crate::optimizer::property::FunctionalDependency;
#[tokio::test]
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/optimizer/plan_node/logical_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use risingwave_common::catalog::TableVersionId;
use risingwave_common::error::Result;

use super::generic::GenericPlanRef;
use super::utils::impl_distill_by_unit;
use super::{
gen_filter_and_pushdown, generic, BatchUpdate, ColPrunable, ExprRewritable, LogicalProject,
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/optimizer/plan_node/merge_eq_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use std::collections::HashMap;
use std::hash::Hash;

use super::generic::GenericPlanRef;
use super::{EndoPlan, LogicalShare, PlanNodeId, PlanRef, PlanTreeNodeUnary, VisitPlan};
use crate::optimizer::plan_visitor;
use crate::utils::{Endo, Visit};
Expand Down
38 changes: 34 additions & 4 deletions src/frontend/src/optimizer/plan_node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,28 @@ impl PlanTreeNode for PlanRef {
}
}

impl GenericPlanRef for PlanRef {
impl PlanNodeMeta for PlanRef {
fn node_type(&self) -> PlanNodeType {
self.0.node_type()
}

fn plan_base(&self) -> &PlanBase {
self.0.plan_base()
}

fn convention(&self) -> Convention {
self.0.convention()
}
}

impl<P> GenericPlanRef for P
where
P: PlanNodeMeta + Eq + Hash,
{
fn id(&self) -> PlanNodeId {
self.plan_base().id()
}

fn schema(&self) -> &Schema {
self.plan_base().schema()
}
Expand All @@ -437,13 +458,19 @@ impl GenericPlanRef for PlanRef {
}
}

impl PhysicalPlanRef for PlanRef {
impl<P> PhysicalPlanRef for P
where
P: PlanNodeMeta + Eq + Hash,
{
fn distribution(&self) -> &Distribution {
self.plan_base().distribution()
}
}

impl StreamPlanRef for PlanRef {
impl<P> StreamPlanRef for P
where
P: PlanNodeMeta + Eq + Hash,
{
fn append_only(&self) -> bool {
self.plan_base().append_only()
}
Expand All @@ -457,7 +484,10 @@ impl StreamPlanRef for PlanRef {
}
}

impl BatchPlanRef for PlanRef {
impl<P> BatchPlanRef for P
where
P: PlanNodeMeta + Eq + Hash,
{
fn order(&self) -> &Order {
self.plan_base().order()
}
Expand Down
Loading

0 comments on commit 636d235

Please sign in to comment.