reifydb_engine/vm/volcano/
environment.rs1use std::sync::Arc;
5
6use reifydb_core::value::column::{columns::Columns, headers::ColumnHeaders};
7use reifydb_transaction::transaction::Transaction;
8
9use crate::{
10 Result,
11 environment::create_env_columns,
12 vm::volcano::query::{QueryContext, QueryNode},
13};
14
15pub(crate) struct EnvironmentNode {
16 context: Option<Arc<QueryContext>>,
17 executed: bool,
18}
19
20impl EnvironmentNode {
21 pub fn new() -> Self {
22 Self {
23 context: None,
24 executed: false,
25 }
26 }
27}
28
29impl QueryNode for EnvironmentNode {
30 fn initialize<'a>(&mut self, _rx: &mut Transaction<'a>, ctx: &QueryContext) -> Result<()> {
31 self.context = Some(Arc::new(ctx.clone()));
33 Ok(())
34 }
35
36 fn next<'a>(&mut self, _rx: &mut Transaction<'a>, _ctx: &mut QueryContext) -> Result<Option<Columns>> {
37 debug_assert!(self.context.is_some(), "EnvironmentNode::next() called before initialize()");
38
39 if self.executed {
41 return Ok(None);
42 }
43
44 let columns = create_env_columns();
45 self.executed = true;
46
47 Ok(Some(columns))
48 }
49
50 fn headers(&self) -> Option<ColumnHeaders> {
51 None
53 }
54}