Skip to content

Commit

Permalink
switch to deterministic hasher
Browse files Browse the repository at this point in the history
  • Loading branch information
oflatt committed Oct 25, 2024
1 parent 5d637f2 commit 334f911
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@

use std::fmt::Display;

use symbol_table::DeterministicHashBuilder;

use crate::core::SpecializedPrimitive;
#[allow(unused_imports)]
use crate::*;

pub(crate) type BuildHasher = std::hash::BuildHasherDefault<rustc_hash::FxHasher>;

pub(crate) type HashMap<K, V> = hashbrown::HashMap<K, V, BuildHasher>;
pub(crate) type HashSet<K> = hashbrown::HashSet<K, BuildHasher>;
/// Use deterministic hasher to make egglog deterministic
/// when rule application order matters.
pub(crate) type HashMap<K, V> = hashbrown::HashMap<K, V, DeterministicHashBuilder>;
pub(crate) type HashSet<K> = hashbrown::HashSet<K, DeterministicHashBuilder>;

/// Index maps don't need deterministic hashing,
/// since iteration order is guaranteed to be insertion order.
pub type IndexMap<K, V> = indexmap::IndexMap<K, V, BuildHasher>;
pub type IndexSet<K> = indexmap::IndexSet<K, BuildHasher>;

Expand Down

0 comments on commit 334f911

Please sign in to comment.