Skip to main content

reifydb_sub_flow/operator/
apply.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2025 ReifyDB
3
4use std::sync::Arc;
5
6use reifydb_core::{
7	interface::{catalog::flow::FlowNodeId, change::Change},
8	value::column::columns::Columns,
9};
10use reifydb_type::{
11	Result,
12	value::{datetime::DateTime, row_number::RowNumber},
13};
14
15use crate::{
16	operator::{BoxedOperator, Operator, Operators},
17	transaction::FlowTransaction,
18};
19
20pub struct ApplyOperator {
21	parent: Arc<Operators>,
22	node: FlowNodeId,
23	inner: BoxedOperator,
24}
25
26impl ApplyOperator {
27	pub fn new(parent: Arc<Operators>, node: FlowNodeId, inner: BoxedOperator) -> Self {
28		Self {
29			parent,
30			node,
31			inner,
32		}
33	}
34}
35
36impl Operator for ApplyOperator {
37	fn id(&self) -> FlowNodeId {
38		self.node
39	}
40
41	fn apply(&self, txn: &mut FlowTransaction, change: Change) -> Result<Change> {
42		self.inner.apply(txn, change)
43	}
44
45	fn tick(&self, txn: &mut FlowTransaction, timestamp: DateTime) -> Result<Option<Change>> {
46		self.inner.tick(txn, timestamp)
47	}
48
49	fn pull(&self, txn: &mut FlowTransaction, rows: &[RowNumber]) -> Result<Columns> {
50		self.parent.pull(txn, rows)
51	}
52}