Compare rows based on their graph entity identities This is the correct approach for set operations on graph data
(&self, row1: &Row, row2: &Row)
| 9504 | /// Compare rows based on their graph entity identities |
| 9505 | /// This is the correct approach for set operations on graph data |
| 9506 | fn rows_equal_by_identity(&self, row1: &Row, row2: &Row) -> bool { |
| 9507 | // If no entities are tracked in either row, fall back to value comparison |
| 9508 | if row1.source_entities.is_empty() || row2.source_entities.is_empty() { |
| 9509 | return self.rows_equal_by_values(row1, row2); |
| 9510 | } |
| 9511 | |
| 9512 | // Check if all tracked entities match |
| 9513 | if row1.source_entities.len() != row2.source_entities.len() { |
| 9514 | return false; |
| 9515 | } |
| 9516 | |
| 9517 | // All entities must match |
| 9518 | for (var, entity1) in &row1.source_entities { |
| 9519 | match row2.source_entities.get(var) { |
| 9520 | Some(entity2) if entity1 == entity2 => continue, |
| 9521 | _ => return false, |
| 9522 | } |
| 9523 | } |
| 9524 | true |
| 9525 | } |
| 9526 | |
| 9527 | /// Compare rows based on their values (backward compatibility) |
| 9528 | fn rows_equal_by_values(&self, row1: &Row, row2: &Row) -> bool { |
no test coverage detected