MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / execute_intersect

Method execute_intersect

graphlite/src/exec/executor.rs:7758–7900  ·  view source on GitHub ↗

Execute INTERSECT operation

(
        &self,
        left: QueryResult,
        right: QueryResult,
        distinct: bool,
    )

Source from the content-addressed store, hash-verified

7756
7757 /// Execute INTERSECT operation
7758 fn execute_intersect(
7759 &self,
7760 left: QueryResult,
7761 right: QueryResult,
7762 distinct: bool,
7763 ) -> Result<QueryResult, ExecutionError> {
7764 log::debug!("=== EXECUTE_INTERSECT CALLED");
7765 log::debug!(
7766 "Left: {} rows, variables: {:?}",
7767 left.rows.len(),
7768 left.variables
7769 );
7770 log::debug!(
7771 "Right: {} rows, variables: {:?}",
7772 right.rows.len(),
7773 right.variables
7774 );
7775
7776 // Check if we should use identity-based or value-based comparison
7777 let use_identity = left.rows.iter().any(|r| r.has_entities())
7778 || right.rows.iter().any(|r| r.has_entities());
7779
7780 log::debug!(
7781 "Using {} comparison",
7782 if use_identity {
7783 "identity-based"
7784 } else {
7785 "value-based"
7786 }
7787 );
7788
7789 let mut result_rows = Vec::new();
7790
7791 if use_identity {
7792 // Identity-based INTERSECT: compare by source entities
7793 for (left_idx, left_row) in left.rows.iter().enumerate() {
7794 // Skip rows without entities
7795 if !left_row.has_entities() {
7796 log::debug!("Skipping left row {} (no entities)", left_idx);
7797 continue;
7798 }
7799
7800 for (right_idx, right_row) in right.rows.iter().enumerate() {
7801 if !right_row.has_entities() {
7802 log::debug!("Skipping right row {} (no entities)", right_idx);
7803 continue;
7804 }
7805
7806 // Compare by entity identity
7807 if self.rows_equal_by_identity(left_row, right_row) {
7808 log::debug!(
7809 "MATCH (identity): Left row {} matches right row {}",
7810 left_idx,
7811 right_idx
7812 );
7813 result_rows.push(left_row.clone());
7814 break; // Found match, no need to check other right rows
7815 }

Callers 1

execute_set_operationMethod · 0.80

Calls 10

has_entitiesMethod · 0.80
cloneMethod · 0.80
row_contains_nullMethod · 0.80
deduplicate_rowsMethod · 0.80
iterMethod · 0.45
lenMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected