Skip to content
Snippets Groups Projects
Commit ba86c49f authored by Igor Kuznetsov's avatar Igor Kuznetsov
Browse files

feat: add public methods for more usefully

parent 70056c8b
No related branches found
No related tags found
1 merge request!1414sbroad import
......@@ -2,6 +2,17 @@
//!
//! Contains the logical plan tree and helpers.
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use expression::Expression;
use operator::Relational;
use relation::Table;
use crate::errors::QueryPlannerError;
use crate::ir::value::Value;
pub mod distribution;
pub mod expression;
pub mod helpers;
......@@ -10,13 +21,6 @@ pub mod relation;
pub mod tree;
pub mod value;
use crate::errors::QueryPlannerError;
use expression::Expression;
use operator::Relational;
use relation::Table;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
/// Plan tree node.
///
/// There are two kinds of node variants: expressions and relational
......@@ -178,6 +182,38 @@ impl Plan {
}
map
}
#[must_use]
pub fn next_id(&self) -> usize {
self.nodes.next_id()
}
/// Add constant value to the plan.
pub fn add_const(&mut self, v: Value) -> usize {
self.nodes.add_const(v)
}
/// Add condition note to the plan.
///
/// # Errors
/// Returns `QueryPlannerError` when the condition node can't append'.
pub fn add_cond(
&mut self,
left: usize,
op: operator::Bool,
right: usize,
) -> Result<usize, QueryPlannerError> {
self.nodes.add_bool(left, op, right)
}
/// Set top node of plan
/// # Errors
/// - top node doesn't exist in AST
pub fn set_top(&mut self, top: usize) -> Result<(), QueryPlannerError> {
self.get_node(top)?;
self.top = Some(top);
Ok(())
}
}
#[cfg(test)]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment