Skip to content

Commit

Permalink
Chore/remove useless dependencies (#240)
Browse files Browse the repository at this point in the history
* chore: remove useless dependencies `lazy_static` & `integer-encoding`

* chore: remove useless dependencies `rand` & `strum_macros` & `tracing`

* chore: update `describe.slt`

* ci: cache rust dependencies

* ci: remove cache
  • Loading branch information
KKould authored Nov 10, 2024
1 parent 104c230 commit 907b952
Show file tree
Hide file tree
Showing 41 changed files with 422 additions and 510 deletions.
24 changes: 11 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,41 +34,39 @@ harness = false

[dependencies]
ahash = { version = "0.8" }
async-trait = { version = "0.1", optional = true }
bincode = { version = "1" }
bytes = { version = "1" }
chrono = { version = "0.4" }
clap = { version = "4.5", features = ["derive"], optional = true }
comfy-table = { version = "7" }
csv = { version = "1" }
encode_unicode = { version = "1" }
dirs = { version = "5" }
env_logger = { version = "0.11", optional = true }
futures = { version = "0.3", optional = true }
integer-encoding = { version = "3" }
itertools = { version = "0.12" }
lazy_static = { version = "1" }
log = { version = "0.4", optional = true }
ordered-float = { version = "4" }
paste = { version = "1" }
parking_lot = { version = "0.12", features = ["arc_lock"] }
petgraph = { version = "0.6" }
pgwire = { version = "0.19", optional = true }
rand = { version = "0.9.0-alpha" }
regex = { version = "1" }
rocksdb = { version = "0.22.0" }
rocksdb = { version = "0.22" }
rust_decimal = { version = "1" }
serde = { version = "1", features = ["derive", "rc"] }
fnck_sql_serde_macros = { version = "0.1.0", path = "fnck_sql_serde_macros" }
siphasher = { version = "1", features = ["serde"] }
sqlparser = { version = "0.34", features = ["serde"] }
strum_macros = { version = "0.26.2" }
thiserror = { version = "1" }
tokio = { version = "1.36", features = ["full"], optional = true }
tracing = { version = "0.1" }
typetag = { version = "0.2" }
ulid = { version = "1", features = ["serde"] }

# Feature: net
async-trait = { version = "0.1", optional = true }
clap = { version = "4.5", features = ["derive"], optional = true }
env_logger = { version = "0.11", optional = true }
futures = { version = "0.3", optional = true }
log = { version = "0.4", optional = true }
pgwire = { version = "0.19", optional = true }
tokio = { version = "1.36", features = ["full"], optional = true }


[dev-dependencies]
cargo-tarpaulin = { version = "0.27" }
criterion = { version = "0.5", features = ["html_reports"] }
Expand Down
36 changes: 18 additions & 18 deletions src/execution/dql/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ use crate::storage::{StatisticsMetaCache, TableCache, Transaction, ViewCache};
use crate::throw;
use crate::types::tuple::Tuple;
use crate::types::value::{DataValue, Utf8Type};
use lazy_static::lazy_static;
use sqlparser::ast::CharLengthUnits;
use std::sync::LazyLock;

lazy_static! {
static ref PRIMARY_KEY_TYPE: DataValue = DataValue::Utf8 {
value: Some(String::from("PRIMARY")),
ty: Utf8Type::Variable(None),
unit: CharLengthUnits::Characters
};
static ref UNIQUE_KEY_TYPE: DataValue = DataValue::Utf8 {
value: Some(String::from("UNIQUE")),
ty: Utf8Type::Variable(None),
unit: CharLengthUnits::Characters
};
static ref EMPTY_KEY_TYPE: DataValue = DataValue::Utf8 {
value: Some(String::from("EMPTY")),
ty: Utf8Type::Variable(None),
unit: CharLengthUnits::Characters
};
}
static PRIMARY_KEY_TYPE: LazyLock<DataValue> = LazyLock::new(|| DataValue::Utf8 {
value: Some(String::from("PRIMARY")),
ty: Utf8Type::Variable(None),
unit: CharLengthUnits::Characters,
});

static UNIQUE_KEY_TYPE: LazyLock<DataValue> = LazyLock::new(|| DataValue::Utf8 {
value: Some(String::from("UNIQUE")),
ty: Utf8Type::Variable(None),
unit: CharLengthUnits::Characters,
});

static EMPTY_KEY_TYPE: LazyLock<DataValue> = LazyLock::new(|| DataValue::Utf8 {
value: Some(String::from("EMPTY")),
ty: Utf8Type::Variable(None),
unit: CharLengthUnits::Characters,
});

pub struct Describe {
table_name: TableName,
Expand Down
6 changes: 2 additions & 4 deletions src/expression/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ use crate::types::tuple::Tuple;
use crate::types::value::{DataValue, Utf8Type};
use crate::types::LogicalType;
use itertools::Itertools;
use lazy_static::lazy_static;
use regex::Regex;
use sqlparser::ast::{CharLengthUnits, TrimWhereField};
use std::cmp;
use std::cmp::Ordering;
use std::sync::LazyLock;

lazy_static! {
static ref NULL_VALUE: DataValue = DataValue::Null;
}
static NULL_VALUE: LazyLock<DataValue> = LazyLock::new(|| DataValue::Null);

macro_rules! eval_to_num {
($num_expr:expr, $tuple:expr, $schema:expr) => {
Expand Down
26 changes: 12 additions & 14 deletions src/function/numbers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,22 @@ use crate::types::tuple::SchemaRef;
use crate::types::tuple::Tuple;
use crate::types::value::DataValue;
use crate::types::LogicalType;
use lazy_static::lazy_static;
use serde::Deserialize;
use serde::Serialize;
use std::sync::Arc;
use std::sync::LazyLock;

lazy_static! {
static ref NUMBERS: TableCatalog = {
TableCatalog::new(
Arc::new("numbers".to_lowercase()),
vec![ColumnCatalog::new(
"number".to_lowercase(),
true,
ColumnDesc::new(LogicalType::Integer, None, false, None).unwrap(),
)],
)
.unwrap()
};
}
static NUMBERS: LazyLock<TableCatalog> = LazyLock::new(|| {
TableCatalog::new(
Arc::new("numbers".to_lowercase()),
vec![ColumnCatalog::new(
"number".to_lowercase(),
true,
ColumnDesc::new(LogicalType::Integer, None, false, None).unwrap(),
)],
)
.unwrap()
});

#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct Numbers {
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
#![feature(iterator_try_collect)]
#![feature(slice_pattern)]
#![feature(stmt_expr_attributes)]
#![feature(random)]
extern crate core;

pub mod binder;
Expand Down
18 changes: 8 additions & 10 deletions src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,14 @@ macro_rules! scala_function {
#[macro_export]
macro_rules! table_function {
($struct_name:ident::$function_name:ident($($arg_ty:expr),*) -> [$($output_name:ident: $output_ty:expr),*] => $closure:expr) => {
::lazy_static::lazy_static! {
static ref $function_name: ::fnck_sql::catalog::table::TableCatalog = {
let mut columns = Vec::new();

$({
columns.push(::fnck_sql::catalog::column::ColumnCatalog::new(stringify!($output_name).to_lowercase(), true, ::fnck_sql::catalog::column::ColumnDesc::new($output_ty, None, false, None).unwrap()));
})*
::fnck_sql::catalog::table::TableCatalog::new(Arc::new(stringify!($function_name).to_lowercase()), columns).unwrap()
};
}
static $function_name: ::std::sync::LazyLock<::fnck_sql::catalog::table::TableCatalog> = ::std::sync::LazyLock::new(|| {
let mut columns = Vec::new();

$({
columns.push(::fnck_sql::catalog::column::ColumnCatalog::new(stringify!($output_name).to_lowercase(), true, ::fnck_sql::catalog::column::ColumnDesc::new($output_ty, None, false, None).unwrap()));
})*
::fnck_sql::catalog::table::TableCatalog::new(Arc::new(stringify!($function_name).to_lowercase()), columns).unwrap()
});

#[derive(Debug, ::serde::Serialize, ::serde::Deserialize)]
pub(crate) struct $struct_name {
Expand Down
5 changes: 2 additions & 3 deletions src/optimizer/core/cm_sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use crate::expression::range_detacher::Range;
use crate::serdes::{ReferenceSerialization, ReferenceTables};
use crate::storage::{TableCache, Transaction};
use crate::types::value::DataValue;
use rand::RngCore;
use siphasher::sip::SipHasher13;
use std::borrow::Borrow;
use std::hash::{Hash, Hasher};
use std::io::{Read, Write};
use std::marker::PhantomData;
use std::random::random;
use std::{cmp, mem};

pub(crate) type FastHasher = SipHasher13;
Expand Down Expand Up @@ -138,8 +138,7 @@ impl<K: Hash> CountMinSketch<K> {
}

fn sip_new() -> FastHasher {
let mut rng = rand::thread_rng();
FastHasher::new_with_keys(rng.next_u64(), rng.next_u64())
FastHasher::new_with_keys(random(), random())
}

fn offset<Q: ?Sized + Hash>(&self, hashes: &mut [u64; 2], key: &Q, k_i: usize) -> usize
Expand Down
14 changes: 5 additions & 9 deletions src/optimizer/rule/implementation/ddl/add_column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ use crate::optimizer::core::statistics_meta::StatisticMetaLoader;
use crate::planner::operator::{Operator, PhysicalOption};
use crate::single_mapping;
use crate::storage::Transaction;
use lazy_static::lazy_static;
use std::sync::LazyLock;

lazy_static! {
static ref ADD_COLUMN_PATTERN: Pattern = {
Pattern {
predicate: |op| matches!(op, Operator::AddColumn(_)),
children: PatternChildrenPredicate::None,
}
};
}
static ADD_COLUMN_PATTERN: LazyLock<Pattern> = LazyLock::new(|| Pattern {
predicate: |op| matches!(op, Operator::AddColumn(_)),
children: PatternChildrenPredicate::None,
});

#[derive(Clone)]
pub struct AddColumnImplementation;
Expand Down
14 changes: 5 additions & 9 deletions src/optimizer/rule/implementation/ddl/create_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ use crate::optimizer::core::statistics_meta::StatisticMetaLoader;
use crate::planner::operator::{Operator, PhysicalOption};
use crate::single_mapping;
use crate::storage::Transaction;
use lazy_static::lazy_static;
use std::sync::LazyLock;

lazy_static! {
static ref CREATE_TABLE_PATTERN: Pattern = {
Pattern {
predicate: |op| matches!(op, Operator::CreateTable(_)),
children: PatternChildrenPredicate::None,
}
};
}
static CREATE_TABLE_PATTERN: LazyLock<Pattern> = LazyLock::new(|| Pattern {
predicate: |op| matches!(op, Operator::CreateTable(_)),
children: PatternChildrenPredicate::None,
});

#[derive(Clone)]
pub struct CreateTableImplementation;
Expand Down
14 changes: 5 additions & 9 deletions src/optimizer/rule/implementation/ddl/drop_column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ use crate::optimizer::core::statistics_meta::StatisticMetaLoader;
use crate::planner::operator::{Operator, PhysicalOption};
use crate::single_mapping;
use crate::storage::Transaction;
use lazy_static::lazy_static;
use std::sync::LazyLock;

lazy_static! {
static ref DROP_COLUMN_PATTERN: Pattern = {
Pattern {
predicate: |op| matches!(op, Operator::DropColumn(_)),
children: PatternChildrenPredicate::None,
}
};
}
static DROP_COLUMN_PATTERN: LazyLock<Pattern> = LazyLock::new(|| Pattern {
predicate: |op| matches!(op, Operator::DropColumn(_)),
children: PatternChildrenPredicate::None,
});

#[derive(Clone)]
pub struct DropColumnImplementation;
Expand Down
14 changes: 5 additions & 9 deletions src/optimizer/rule/implementation/ddl/drop_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ use crate::optimizer::core::statistics_meta::StatisticMetaLoader;
use crate::planner::operator::{Operator, PhysicalOption};
use crate::single_mapping;
use crate::storage::Transaction;
use lazy_static::lazy_static;
use std::sync::LazyLock;

lazy_static! {
static ref DROP_TABLE_PATTERN: Pattern = {
Pattern {
predicate: |op| matches!(op, Operator::DropTable(_)),
children: PatternChildrenPredicate::None,
}
};
}
static DROP_TABLE_PATTERN: LazyLock<Pattern> = LazyLock::new(|| Pattern {
predicate: |op| matches!(op, Operator::DropTable(_)),
children: PatternChildrenPredicate::None,
});

#[derive(Clone)]
pub struct DropTableImplementation;
Expand Down
14 changes: 5 additions & 9 deletions src/optimizer/rule/implementation/ddl/truncate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ use crate::optimizer::core::statistics_meta::StatisticMetaLoader;
use crate::planner::operator::{Operator, PhysicalOption};
use crate::single_mapping;
use crate::storage::Transaction;
use lazy_static::lazy_static;
use std::sync::LazyLock;

lazy_static! {
static ref TRUNCATE_PATTERN: Pattern = {
Pattern {
predicate: |op| matches!(op, Operator::DropTable(_)),
children: PatternChildrenPredicate::None,
}
};
}
static TRUNCATE_PATTERN: LazyLock<Pattern> = LazyLock::new(|| Pattern {
predicate: |op| matches!(op, Operator::DropTable(_)),
children: PatternChildrenPredicate::None,
});

#[derive(Clone)]
pub struct TruncateImplementation;
Expand Down
14 changes: 5 additions & 9 deletions src/optimizer/rule/implementation/dml/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ use crate::optimizer::core::statistics_meta::StatisticMetaLoader;
use crate::planner::operator::{Operator, PhysicalOption};
use crate::single_mapping;
use crate::storage::Transaction;
use lazy_static::lazy_static;
use std::sync::LazyLock;

lazy_static! {
static ref ANALYZE_PATTERN: Pattern = {
Pattern {
predicate: |op| matches!(op, Operator::Analyze(_)),
children: PatternChildrenPredicate::None,
}
};
}
static ANALYZE_PATTERN: LazyLock<Pattern> = LazyLock::new(|| Pattern {
predicate: |op| matches!(op, Operator::Analyze(_)),
children: PatternChildrenPredicate::None,
});

#[derive(Clone)]
pub struct AnalyzeImplementation;
Expand Down
14 changes: 5 additions & 9 deletions src/optimizer/rule/implementation/dml/copy_from_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ use crate::optimizer::core::statistics_meta::StatisticMetaLoader;
use crate::planner::operator::{Operator, PhysicalOption};
use crate::single_mapping;
use crate::storage::Transaction;
use lazy_static::lazy_static;
use std::sync::LazyLock;

lazy_static! {
static ref COPY_FROM_FILE_PATTERN: Pattern = {
Pattern {
predicate: |op| matches!(op, Operator::CopyFromFile(_)),
children: PatternChildrenPredicate::None,
}
};
}
static COPY_FROM_FILE_PATTERN: LazyLock<Pattern> = LazyLock::new(|| Pattern {
predicate: |op| matches!(op, Operator::CopyFromFile(_)),
children: PatternChildrenPredicate::None,
});

#[derive(Clone)]
pub struct CopyFromFileImplementation;
Expand Down
14 changes: 5 additions & 9 deletions src/optimizer/rule/implementation/dml/copy_to_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ use crate::optimizer::core::statistics_meta::StatisticMetaLoader;
use crate::planner::operator::{Operator, PhysicalOption};
use crate::single_mapping;
use crate::storage::Transaction;
use lazy_static::lazy_static;
use std::sync::LazyLock;

lazy_static! {
static ref COPY_TO_FILE_PATTERN: Pattern = {
Pattern {
predicate: |op| matches!(op, Operator::CopyToFile(_)),
children: PatternChildrenPredicate::None,
}
};
}
static COPY_TO_FILE_PATTERN: LazyLock<Pattern> = LazyLock::new(|| Pattern {
predicate: |op| matches!(op, Operator::CopyToFile(_)),
children: PatternChildrenPredicate::None,
});

#[derive(Clone)]
pub struct CopyToFileImplementation;
Expand Down
Loading

0 comments on commit 907b952

Please sign in to comment.