Skip to content

Commit

Permalink
fix: Termination condition and improve names for distinct
Browse files Browse the repository at this point in the history
  • Loading branch information
AmrDeveloper committed Jun 15, 2024
1 parent 394e336 commit bc7b841
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions crates/gitql-engine/src/engine_distinct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(crate) fn apply_distinct_operator(
object: &mut GitQLObject,
hidden_selections: &[String],
) {
if !object.is_empty() {
if object.is_empty() {
return;
}

Expand Down Expand Up @@ -50,9 +50,9 @@ fn apply_distinct_all_operation(object: &mut GitQLObject, hidden_selections: &[S
}

// Compute the hash for row of values
let mut hash = DefaultHasher::new();
row_values.hash(&mut hash);
let values_hash = hash.finish();
let mut hasher = DefaultHasher::new();
row_values.hash(&mut hasher);
let values_hash = hasher.finish();

// If this hash is unique, insert the row
if values_set.insert(values_hash) {
Expand Down Expand Up @@ -86,12 +86,11 @@ fn apply_distinct_on_operation(object: &mut GitQLObject, distinct_fields: &[Stri
}

// Compute the hash for row of values
let mut hash = DefaultHasher::new();
row_values.hash(&mut hash);
let values_hash = hash.finish();
let mut hasher = DefaultHasher::new();
row_values.hash(&mut hasher);

// If this hash is unique, insert the row
if values_set.insert(values_hash) {
if values_set.insert(hasher.finish()) {
new_objects.rows.push(Row {
values: object.values.clone(),
});
Expand Down

0 comments on commit bc7b841

Please sign in to comment.