From 7aa493d5e28aa228ec865932392245448102e08a Mon Sep 17 00:00:00 2001 From: Denis Smirnov <sd@picodata.io> Date: Tue, 4 Jul 2023 11:38:09 +0700 Subject: [PATCH] refactoring: remove redundant sql function for bucket calculation INSERT command in the SQL library (sbroad) was refactored. Now we don't need a custom SQL function to calculate bucket ids. So, remove redundant functions from picodata SQL module. --- sbroad | 2 +- src/lib.rs | 20 -------------------- src/sql.rs | 10 +--------- src/sql/exports | 1 - 4 files changed, 2 insertions(+), 31 deletions(-) diff --git a/sbroad b/sbroad index aafa4f7af8..57bfc48342 160000 --- a/sbroad +++ b/sbroad @@ -1 +1 @@ -Subproject commit aafa4f7af83f14f0db175f92bf6e66d56f97abb3 +Subproject commit 57bfc48342fd2b9b4c071cdb644f07d321f041a6 diff --git a/src/lib.rs b/src/lib.rs index ec1fcf5e0f..b1edbe4aee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -109,26 +109,6 @@ fn init_sbroad() { "sbroad/sbroad-core/src/core-storage.lua" ); - // Create SQL function for bucket calculation. - lua.exec( - r#" - box.schema.func.create('BUCKET_ID', { - language = 'Lua', - body = [[ - function(x) - return box.func['.calculate_bucket_id']:call({ x }) - end - ]], - if_not_exists = true, - param_list = {'string'}, - returns = 'unsigned', - aggregate = 'none', - exports = {'SQL'}, - }) - "#, - ) - .unwrap(); - lua.exec( r#" _G.pico.sql = require('sbroad').sql; diff --git a/src/sql.rs b/src/sql.rs index 09ed647280..d06036a1e3 100644 --- a/src/sql.rs +++ b/src/sql.rs @@ -2,8 +2,7 @@ use crate::traft; use ::tarantool::proc; use ::tarantool::tuple::{RawByteBuf, RawBytes}; use sbroad::backend::sql::ir::{EncodedPatternWithParams, PatternWithParams}; -use sbroad::ir::value::Value; -use sbroad_picodata::api::{determine_bucket_id, dispatch_sql, execute_sql}; +use sbroad_picodata::api::{dispatch_sql, execute_sql}; #[proc(packed_args)] pub fn dispatch_query(encoded_params: EncodedPatternWithParams) -> traft::Result<RawByteBuf> { @@ -17,10 +16,3 @@ pub fn execute(raw: &RawBytes) -> traft::Result<RawByteBuf> { let bytes = execute_sql(raw)?; Ok(RawByteBuf::from(bytes)) } - -#[proc] -pub fn calculate_bucket_id(rec: String) -> traft::Result<u64> { - let bucket_str = Value::from(rec); - let bucket_id = determine_bucket_id(&[&bucket_str])?; - Ok(bucket_id) -} diff --git a/src/sql/exports b/src/sql/exports index 5a38ee0bae..e178fd8ecc 100644 --- a/src/sql/exports +++ b/src/sql/exports @@ -1,3 +1,2 @@ dispatch_query execute -calculate_bucket_id -- GitLab