diff --git a/sbroad-core/src/executor/engine/helpers.rs b/sbroad-core/src/executor/engine/helpers.rs index a33f8b6da621d687fc395e814c4e735909cb9d21..e8478458966eae1874fdae0f5532739900ab6268 100644 --- a/sbroad-core/src/executor/engine/helpers.rs +++ b/sbroad-core/src/executor/engine/helpers.rs @@ -1290,7 +1290,7 @@ impl RequiredPlanInfo for QueryInfo<'_> { } fn vdbe_max_steps(&self) -> u64 { - self.required.options.execute_options.vdbe_max_steps() + self.required.options.vdbe_max_steps } fn vtable_max_rows(&self) -> u64 { @@ -1338,7 +1338,7 @@ impl RequiredPlanInfo for EncodedQueryInfo<'_> { } fn vdbe_max_steps(&self) -> u64 { - self.required.options.execute_options.vdbe_max_steps() + self.required.options.vdbe_max_steps } fn vtable_max_rows(&self) -> u64 { diff --git a/sbroad-core/src/executor/ir.rs b/sbroad-core/src/executor/ir.rs index 74362719341cfec2e429bc41c0ae7352e7cade9e..826072569ac8e9e1dfb365b1789fa8694c555893 100644 --- a/sbroad-core/src/executor/ir.rs +++ b/sbroad-core/src/executor/ir.rs @@ -21,7 +21,7 @@ use crate::ir::operator::{OrderByElement, OrderByEntity}; use crate::ir::relation::SpaceEngine; use crate::ir::transformation::redistribution::{MotionOpcode, MotionPolicy}; use crate::ir::tree::traversal::{LevelNode, PostOrder}; -use crate::ir::{ExecuteOptions, Plan}; +use crate::ir::Plan; use crate::otm::child_span; use sbroad_proc::otm_child_span; @@ -108,11 +108,6 @@ impl ExecutionPlan { self.plan.options.vtable_max_rows } - #[must_use] - pub fn get_execute_options(&self) -> &ExecuteOptions { - &self.plan.options.execute_options - } - #[allow(dead_code)] pub fn get_mut_ir_plan(&mut self) -> &mut Plan { &mut self.plan diff --git a/sbroad-core/src/ir.rs b/sbroad-core/src/ir.rs index f03c9fa7181d249bff326c8e0f276d1589c9e978..519df6b343f9b81afc227bedd949a75211404c77 100644 --- a/sbroad-core/src/ir.rs +++ b/sbroad-core/src/ir.rs @@ -11,14 +11,11 @@ use node::{Invalid, NodeAligned}; use serde::{Deserialize, Serialize}; use smol_str::{format_smolstr, SmolStr, ToSmolStr}; use std::cell::{RefCell, RefMut}; -use std::collections::hash_map::IntoIter; use std::collections::{HashMap, HashSet}; use std::fmt::{Display, Formatter}; use std::slice::Iter; use tree::traversal::LevelNode; -use tarantool::tlua; - use operator::Arithmetic; use relation::{Table, Type}; @@ -29,7 +26,6 @@ use crate::errors::Entity::Query; use crate::errors::{Action, Entity, SbroadError, TypeError}; use crate::executor::engine::helpers::to_user; use crate::executor::engine::TableVersionMap; -use crate::ir::helpers::RepeatableState; use crate::ir::node::plugin::{MutPlugin, Plugin}; use crate::ir::node::{ Alias, ArenaType, ArithmeticExpr, BoolExpr, Case, Cast, Concat, Constant, ExprInParentheses, @@ -44,7 +40,7 @@ use crate::ir::tree::traversal::{ }; use crate::ir::undo::TransformationLog; use crate::ir::value::Value; -use crate::{collection, error, warn}; +use crate::warn; use self::node::Like; @@ -609,92 +605,6 @@ impl Display for OptionKind { } } -/// Options passed to `box.execute` -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone, Eq)] -pub struct ExecuteOptions(HashMap<OptionKind, Value, RepeatableState>); - -impl ExecuteOptions { - #[must_use] - pub fn new(opts: HashMap<OptionKind, Value, RepeatableState>) -> Self { - ExecuteOptions(opts) - } - - #[must_use] - pub fn to_iter(self) -> IntoIter<OptionKind, Value> { - self.0.into_iter() - } - - pub fn insert(&mut self, kind: OptionKind, value: Value) -> Option<Value> { - self.0.insert(kind, value) - } - - #[must_use] - pub fn vdbe_max_steps(&self) -> u64 { - self.0 - .get(&OptionKind::VdbeMaxSteps) - .map_or(DEFAULT_VDBE_MAX_STEPS, |v| { - if let Value::Unsigned(steps) = v { - *steps - } else { - DEFAULT_VDBE_MAX_STEPS - } - }) - } - - #[must_use] - pub fn vtable_max_rows(&self) -> u64 { - self.0 - .get(&OptionKind::VTableMaxRows) - .map_or(DEFAULT_VTABLE_MAX_ROWS, |v| { - if let Value::Unsigned(rows) = v { - *rows - } else { - DEFAULT_VTABLE_MAX_ROWS - } - }) - } -} - -impl<L> tlua::PushInto<L> for ExecuteOptions -where - L: tlua::AsLua, -{ - type Err = String; - - #[allow(unreachable_code)] - fn push_into_lua(self, lua: L) -> Result<tlua::PushGuard<L>, (Self::Err, L)> { - let to_push: Vec<Vec<(String, Value)>> = if self.0.is_empty() { - vec![] - } else { - vec![self - .0 - .into_iter() - .map(|(kind, value)| (kind.to_string(), value)) - .collect()] - }; - match to_push.push_into_lua(lua) { - Ok(r) => Ok(r), - Err(e) => { - error!( - Option::from("push ExecuteOptions into lua"), - &format!("{:?}", e.0), - ); - Err((e.0.to_string(), e.1)) - } - } - } -} - -impl Default for ExecuteOptions { - fn default() -> Self { - let exec_opts: HashMap<OptionKind, Value, RepeatableState> = collection!(( - OptionKind::VdbeMaxSteps, - Value::Unsigned(DEFAULT_VDBE_MAX_STEPS) - )); - ExecuteOptions(exec_opts) - } -} - /// SQL options specified by user in `option(..)` clause. /// /// Note: ddl options are handled separately. @@ -711,21 +621,21 @@ pub struct Options { pub vtable_max_rows: u64, /// Options passed to `box.execute` function on storages. Currently there is only one option /// `vdbe_max_steps`. - pub execute_options: ExecuteOptions, + pub vdbe_max_steps: u64, } impl Default for Options { fn default() -> Self { - Options::new(DEFAULT_VTABLE_MAX_ROWS, ExecuteOptions::default()) + Options::new(DEFAULT_VTABLE_MAX_ROWS, DEFAULT_VDBE_MAX_STEPS) } } impl Options { #[must_use] - pub fn new(vtable_max_rows: u64, execute_options: ExecuteOptions) -> Self { + pub fn new(vtable_max_rows: u64, vdbe_max_steps: u64) -> Self { Options { vtable_max_rows, - execute_options, + vdbe_max_steps, } } } @@ -977,8 +887,8 @@ impl Plan { &format!("Option {} does not apply for insert with values", opt.kind) ); } - if let Value::Unsigned(_) = val { - self.options.execute_options.insert(opt.kind, val); + if let Value::Unsigned(num) = val { + self.options.vdbe_max_steps = num; } else { return Err(SbroadError::Invalid( Entity::OptionSpec, diff --git a/sbroad-core/src/ir/explain.rs b/sbroad-core/src/ir/explain.rs index be4ac98f42e92ec86f03015df9c4448db52efbe5..b555e2e35a246bb7aa4d409776c9c003727f9c21 100644 --- a/sbroad-core/src/ir/explain.rs +++ b/sbroad-core/src/ir/explain.rs @@ -1062,9 +1062,10 @@ impl FullExplain { pub fn new(ir: &Plan, top_id: NodeId) -> Result<Self, SbroadError> { let mut stack: Vec<ExplainTreePart> = Vec::new(); let mut result = FullExplain::default(); - result - .exec_options - .extend(ir.options.execute_options.clone().to_iter()); + result.exec_options.push(( + OptionKind::VdbeMaxSteps, + Value::Unsigned(ir.options.vdbe_max_steps), + )); result.exec_options.push(( OptionKind::VTableMaxRows, Value::Unsigned(ir.options.vtable_max_rows),