Skip to content

Commit 2ae6c4e

Browse files
authored
Use non-cryptographic hashing algorithm for internal maps (#582)
* Use non-cryptographic hashing algorithm for internal maps * Clippy & cargo fix for rust 1.88
1 parent df46296 commit 2ae6c4e

File tree

26 files changed

+64
-70
lines changed

26 files changed

+64
-70
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [Unreleased]
1010
### Changed
11+
- Changed many internal `HashMap`s to use `rustc-hash`'s `FxHash`
1112

1213
### Added
1314

extension/partiql-extension-ddl/src/ddl.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@ impl PartiqlDdlEncoder for PartiqlBasicDdlEncoder {
208208
Ok(output)
209209
} else {
210210
Err(ShapeEncodingError::UnsupportedEncoding(format!(
211-
"Unsupported top level type {:?}",
212-
ty
211+
"Unsupported top level type {ty:?}"
213212
)))
214213
}
215214
}

extension/partiql-extension-ion/src/boxed_ion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ mod tests {
875875
flatten_dump(c.expect("boxed ion element"))
876876
}
877877
} else {
878-
println!("{:?}", doc);
878+
println!("{doc:?}");
879879
}
880880
}
881881

extension/partiql-extension-visualize/src/ast_to_dot.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ fn lit_to_str(ast: &ast::Lit) -> String {
186186
Lit::DoubleLit(l) => l.to_string(),
187187
Lit::BoolLit(l) => (if *l { "TRUE" } else { "FALSE" }).to_string(),
188188
Lit::EmbeddedDocLit(l, typ) => format!("`{}`::{}", l, type_to_str(typ)),
189-
Lit::CharStringLit(l) => format!("'{}'", l),
190-
Lit::NationalCharStringLit(l) => format!("'{}'", l),
191-
Lit::BitStringLit(l) => format!("b'{}'", l),
192-
Lit::HexStringLit(l) => format!("x'{}'", l),
189+
Lit::CharStringLit(l) => format!("'{l}'"),
190+
Lit::NationalCharStringLit(l) => format!("'{l}'"),
191+
Lit::BitStringLit(l) => format!("b'{l}'"),
192+
Lit::HexStringLit(l) => format!("x'{l}'"),
193193
Lit::BagLit(_b) => todo!("bag literals"),
194194
Lit::ListLit(_b) => todo!("list literals"),
195195
Lit::StructLit(_b) => todo!("struct literals"),
@@ -220,7 +220,7 @@ fn custom_type_part_to_str(part: &ast::CustomTypePart) -> String {
220220
.map(custom_type_param_to_str)
221221
.collect::<Vec<_>>()
222222
.join(",");
223-
format!("{}({})", name, args)
223+
format!("{name}({args})")
224224
}
225225
}
226226
}
@@ -235,7 +235,7 @@ fn type_to_str(ty: &ast::Type) -> String {
235235
.map(custom_type_part_to_str)
236236
.collect::<Vec<_>>()
237237
.join(" "),
238-
_ => format!("{:?}", ty),
238+
_ => format!("{ty:?}"),
239239
}
240240
}
241241

@@ -467,7 +467,7 @@ impl ToDot<ast::VarRef> for AstToDot {
467467
let lbl = symbol_primitive_to_label(&ast.name);
468468
let lbl = match &ast.qualifier {
469469
ast::ScopeQualifier::Unqualified => lbl,
470-
ast::ScopeQualifier::Qualified => format!("@{}", lbl),
470+
ast::ScopeQualifier::Qualified => format!("@{lbl}"),
471471
};
472472
let id = out.node_auto_labelled(&lbl).id();
473473

extension/partiql-extension-visualize/src/plan_to_dot.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl PlanToDot {
6060
)
6161
})
6262
.join(" | ");
63-
format!("{{order by | {} }}", specs)
63+
format!("{{order by | {specs} }}")
6464
}
6565
BindingsOp::LimitOffset(lo) => {
6666
let clauses = [
@@ -148,7 +148,7 @@ fn expr_to_str(expr: &ValueExpr) -> String {
148148
)
149149
}
150150
expr => {
151-
let expr: String = format!("{:?}", expr).escape_default().collect();
151+
let expr: String = format!("{expr:?}").escape_default().collect();
152152
let expr = expr.replace('{', "\\{");
153153
let expr = expr.replace('}', "\\}");
154154
let expr = expr.replace('<', "\\<");

partiql-catalog/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ thiserror = "1.0"
3030
ordered-float = "5"
3131
itertools = "0.14"
3232
unicase = "2.7"
33+
rustc-hash = "2"
3334

3435
dyn-clone = "1"

partiql-catalog/src/catalog.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ use crate::scalar_fn::ScalarFunction;
33
use crate::table_fn::TableFunction;
44
use partiql_common::catalog::{CatalogId, EntryId, ObjectId};
55
use partiql_types::PartiqlShape;
6-
use std::collections::HashMap;
6+
use rustc_hash::FxHashMap;
77
use std::fmt::Debug;
88
use std::sync::atomic::{AtomicU64, Ordering};
99
use thiserror::Error;
1010
use unicase::UniCase;
11-
1211
/// Contains the errors that occur during Catalog related operations
1312
#[derive(Error, Debug, Clone, PartialEq)]
1413
#[error("Catalog error: encountered errors")]
@@ -218,9 +217,9 @@ impl PartiqlCatalog {
218217

219218
#[derive(Debug)]
220219
struct CatalogEntrySet<T> {
221-
entries: HashMap<EntryId, T>,
222-
by_name: HashMap<UniCase<String>, EntryId>,
223-
by_alias: HashMap<UniCase<String>, EntryId>,
220+
entries: FxHashMap<EntryId, T>,
221+
by_name: FxHashMap<UniCase<String>, EntryId>,
222+
by_alias: FxHashMap<UniCase<String>, EntryId>,
224223

225224
next_id: AtomicU64,
226225
}

partiql-common/src/metadata.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -345,24 +345,24 @@ where
345345
if idx > 0 {
346346
write!(f, ", ")?;
347347
}
348-
write!(f, "{}", item)?;
348+
write!(f, "{item}")?;
349349
}
350350
write!(f, "]")
351351
}
352-
PartiqlMetaValue::Bool(v) => write!(f, "{}", v),
353-
PartiqlMetaValue::Decimal(v) => write!(f, "{}", v),
354-
PartiqlMetaValue::Float64(v) => write!(f, "{}", v),
355-
PartiqlMetaValue::Float32(v) => write!(f, "{}", v),
356-
PartiqlMetaValue::Int32(v) => write!(f, "{}", v),
357-
PartiqlMetaValue::Int64(v) => write!(f, "{}", v),
352+
PartiqlMetaValue::Bool(v) => write!(f, "{v}"),
353+
PartiqlMetaValue::Decimal(v) => write!(f, "{v}"),
354+
PartiqlMetaValue::Float64(v) => write!(f, "{v}"),
355+
PartiqlMetaValue::Float32(v) => write!(f, "{v}"),
356+
PartiqlMetaValue::Int32(v) => write!(f, "{v}"),
357+
PartiqlMetaValue::Int64(v) => write!(f, "{v}"),
358358
PartiqlMetaValue::Map(map) => {
359359
write!(f, "{{")?;
360360
for (t, v) in map.iter() {
361-
write!(f, "{}: {} , ", t, v)?;
361+
write!(f, "{t}: {v} , ")?;
362362
}
363363
write!(f, "}}")
364364
}
365-
PartiqlMetaValue::String(v) => write!(f, "{}", v),
365+
PartiqlMetaValue::String(v) => write!(f, "{v}"),
366366
}
367367
}
368368
}

partiql-conformance-test-generator/src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn escape_str(s: &str) -> String {
2929
None => "_".to_string(),
3030
Some(c) => {
3131
if c.is_numeric() {
32-
format!("_{}", snake_case)
32+
format!("_{snake_case}")
3333
} else {
3434
snake_case
3535
}

partiql-eval/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ partiql-extension-ion = { path = "../extension/partiql-extension-ion", version =
3030
ion-rs_old = { version = "0.18", package = "ion-rs" }
3131
lasso = "0.7"
3232
petgraph = "0.7"
33-
fxhash = "0.2"
3433
indexmap = "2"
3534
ordered-float = "5"
3635
itertools = "0.14"

0 commit comments

Comments
 (0)