Skip to content

Commit

Permalink
chore: remove useless dependencies rand & strum_macros & tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
KKould committed Nov 10, 2024
1 parent 93874f6 commit 792c13f
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 14 deletions.
5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,14 @@ ordered-float = { version = "4" }
paste = { version = "1" }
parking_lot = { version = "0.12", features = ["arc_lock"] }
petgraph = { version = "0.6" }
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" }
tracing = { version = "0.1" }
typetag = { version = "0.2" }
ulid = { version = "1", features = ["serde"] }

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
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
21 changes: 17 additions & 4 deletions src/planner/operator/join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ use fnck_sql_serde_macros::ReferenceSerialization;
use itertools::Itertools;
use std::fmt;
use std::fmt::Formatter;
use strum_macros::Display;

#[derive(
Debug, Display, PartialEq, Eq, Clone, Copy, Hash, Ord, PartialOrd, ReferenceSerialization,
)]
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, Ord, PartialOrd, ReferenceSerialization)]
pub enum JoinType {
Inner,
LeftOuter,
Expand Down Expand Up @@ -50,6 +47,22 @@ impl JoinOperator {
}
}

impl fmt::Display for JoinType {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self {
JoinType::Inner => write!(f, "Inner")?,
JoinType::LeftOuter => write!(f, "LeftOuter")?,
JoinType::LeftSemi => write!(f, "LeftSemi")?,
JoinType::LeftAnti => write!(f, "LeftAnti")?,
JoinType::RightOuter => write!(f, "RightOuter")?,
JoinType::Full => write!(f, "Full")?,
JoinType::Cross => write!(f, "Cross")?,
}

Ok(())
}
}

impl fmt::Display for JoinOperator {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "{} Join{}", self.join_type, self.on)?;
Expand Down
40 changes: 37 additions & 3 deletions src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use std::cmp;
use crate::errors::DatabaseError;
use fnck_sql_serde_macros::ReferenceSerialization;
use sqlparser::ast::{CharLengthUnits, ExactNumberInfo, TimezoneInfo};
use strum_macros::AsRefStr;
use ulid::Ulid;

pub type ColumnId = Ulid;
Expand All @@ -28,7 +27,6 @@ pub type ColumnId = Ulid;
Hash,
PartialOrd,
Ord,
AsRefStr,
Serialize,
Deserialize,
ReferenceSerialization,
Expand Down Expand Up @@ -449,7 +447,43 @@ impl TryFrom<sqlparser::ast::DataType> for LogicalType {

impl std::fmt::Display for LogicalType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.as_ref().to_uppercase())
match self {
LogicalType::Invalid => write!(f, "Invalid")?,
LogicalType::SqlNull => write!(f, "SqlNull")?,
LogicalType::Boolean => write!(f, "Boolean")?,
LogicalType::Tinyint => write!(f, "Tinyint")?,
LogicalType::UTinyint => write!(f, "UTinyint")?,
LogicalType::Smallint => write!(f, "Smallint")?,
LogicalType::USmallint => write!(f, "USmallint")?,
LogicalType::Integer => write!(f, "Integer")?,
LogicalType::UInteger => write!(f, "UInteger")?,
LogicalType::Bigint => write!(f, "Bigint")?,
LogicalType::UBigint => write!(f, "UBigint")?,
LogicalType::Float => write!(f, "Float")?,
LogicalType::Double => write!(f, "Double")?,
LogicalType::Char(len, units) => write!(f, "Char({}, {})", len, units)?,
LogicalType::Varchar(len, units) => write!(f, "Varchar({:?}, {})", len, units)?,
LogicalType::Date => write!(f, "Date")?,
LogicalType::DateTime => write!(f, "DateTime")?,
LogicalType::Time => write!(f, "Time")?,
LogicalType::Decimal(precision, scale) => {
write!(f, "Decimal({:?}, {:?})", precision, scale)?
}
LogicalType::Tuple(types) => {
write!(f, "(")?;
let mut first = true;
for ty in types {
if !first {
write!(f, ", ")?;
}
first = false;
write!(f, "{}", ty)?;
}
write!(f, ")")?
}
}

Ok(())
}
}

Expand Down

0 comments on commit 792c13f

Please sign in to comment.