risingwave_frontend/optimizer/plan_node/
batch_get_channel_delta_stats.rs1use risingwave_pb::batch_plan::plan_node::NodeBody;
16
17use super::batch::prelude::*;
18use super::utils::impl_distill_by_unit;
19use super::{
20 BatchPlanRef as PlanRef, ExprRewritable, PlanBase, PlanTreeNodeLeaf, ToBatchPb,
21 ToDistributedBatch, generic,
22};
23use crate::error::Result;
24use crate::optimizer::plan_node::ToLocalBatch;
25use crate::optimizer::property::{Distribution, Order};
26
27#[derive(Debug, Clone, PartialEq, Eq, Hash)]
30pub struct BatchGetChannelDeltaStats {
31 pub base: PlanBase<Batch>,
32 core: generic::GetChannelDeltaStats,
33}
34
35impl PlanTreeNodeLeaf for BatchGetChannelDeltaStats {}
36impl_plan_tree_node_for_leaf! { Batch, BatchGetChannelDeltaStats }
37
38impl BatchGetChannelDeltaStats {
39 pub fn new(core: generic::GetChannelDeltaStats) -> Self {
40 Self::with_dist(core, Distribution::Single)
41 }
42
43 pub fn with_dist(core: generic::GetChannelDeltaStats, dist: Distribution) -> Self {
44 let base = PlanBase::new_batch_with_core(&core, dist, Order::any());
45 Self { base, core }
46 }
47
48 pub fn at_time(&self) -> Option<u64> {
50 self.core.at_time
51 }
52
53 pub fn time_offset(&self) -> Option<u64> {
55 self.core.time_offset
56 }
57}
58
59impl_distill_by_unit!(BatchGetChannelDeltaStats, core, "BatchGetChannelDeltaStats");
60
61impl ToDistributedBatch for BatchGetChannelDeltaStats {
62 fn to_distributed(&self) -> Result<PlanRef> {
63 Ok(Self::with_dist(self.core.clone(), Distribution::Single).into())
64 }
65}
66
67impl ToBatchPb for BatchGetChannelDeltaStats {
68 fn to_batch_prost_body(&self) -> NodeBody {
69 use risingwave_pb::batch_plan::GetChannelDeltaStatsNode;
70
71 NodeBody::GetChannelDeltaStats(GetChannelDeltaStatsNode {
72 at_time: self.core.at_time,
73 time_offset: self.core.time_offset,
74 })
75 }
76}
77
78impl ToLocalBatch for BatchGetChannelDeltaStats {
79 fn to_local(&self) -> Result<PlanRef> {
80 Ok(Self::with_dist(self.core.clone(), Distribution::Single).into())
81 }
82}
83
84impl ExprRewritable<Batch> for BatchGetChannelDeltaStats {}
85
86impl crate::optimizer::plan_node::expr_visitable::ExprVisitable for BatchGetChannelDeltaStats {}