reifydb_sub_flow/operator/stateful/
mod.rs

1// Copyright (c) reifydb.com 2025
2// This file is licensed under the AGPL-3.0-or-later, see license.md file
3
4use reifydb_core::{EncodedKey, interface::BoxedMultiVersionIter, value::encoded::EncodedValues};
5
6mod keyed;
7mod raw;
8mod row_number;
9mod single;
10#[cfg(test)]
11pub mod test_utils;
12mod utils;
13mod window;
14
15pub use keyed::KeyedStateful;
16pub use raw::RawStatefulOperator;
17use reifydb_core::key::{EncodableKey, FlowNodeStateKey};
18pub use row_number::RowNumberProvider;
19pub use single::SingleStateful;
20pub use utils::*;
21pub use window::WindowStateful;
22
23// Iterator wrapper for state entries
24pub struct StateIterator<'a> {
25	pub(crate) inner: BoxedMultiVersionIter<'a>,
26}
27
28impl<'a> Iterator for StateIterator<'a> {
29	type Item = (EncodedKey, EncodedValues);
30
31	fn next(&mut self) -> Option<Self::Item> {
32		self.inner.next().map(|multi| {
33			if let Some(state_key) = FlowNodeStateKey::decode(&multi.key) {
34				(EncodedKey::new(state_key.key), multi.values)
35			} else {
36				(multi.key, multi.values)
37			}
38		})
39	}
40}