Skip to content

Commit

Permalink
Optimized SHA-256 hash function and marked it as immutable and parall…
Browse files Browse the repository at this point in the history
…el_safe for improved performance and parallel query execution. (#10)
  • Loading branch information
analyzer1 authored Sep 26, 2024
1 parent 75b9039 commit 5d9de8b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions extension/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,9 @@ fn source_column() -> Result<
.map(TableIterator::new)
}

#[pg_extern]
fn hash(inputs: &str) -> String {
let mut hasher = Sha256::new();
hasher.update(inputs.as_bytes());
let digest = hasher.finalize();
#[pg_extern(immutable, parallel_safe)]
fn hash(input: &str) -> String {
let digest = Sha256::digest(input.as_bytes());
hex::encode(digest)
}

Expand Down

0 comments on commit 5d9de8b

Please sign in to comment.