Execute a pre-optimized MATCH query (internal, skip optimizer).
(
query: &MatchQuery,
csr: &CsrIndex,
edge_store: &EdgeStore,
frontier_bitmap: Option<&nodedb_types::SurrogateBitmap>,
)
| 59 | |
| 60 | /// Execute a pre-optimized MATCH query (internal, skip optimizer). |
| 61 | fn execute_query( |
| 62 | query: &MatchQuery, |
| 63 | csr: &CsrIndex, |
| 64 | edge_store: &EdgeStore, |
| 65 | frontier_bitmap: Option<&nodedb_types::SurrogateBitmap>, |
| 66 | ) -> Result<MatchOutcome, crate::Error> { |
| 67 | let mut rows: Vec<BindingRow> = vec![HashMap::new()]; |
| 68 | let mut state = ExecutionState::default(); |
| 69 | |
| 70 | for clause in &query.clauses { |
| 71 | let clause_rows = execute_clause(clause, csr, &rows, &mut state, frontier_bitmap)?; |
| 72 | if clause.optional { |
| 73 | rows = left_join_rows(&rows, &clause_rows, clause); |
| 74 | } else { |
| 75 | rows = clause_rows; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | for predicate in &query.where_predicates { |
| 80 | rows = predicates::apply_predicate(&rows, predicate, csr, edge_store, frontier_bitmap)?; |
| 81 | } |
| 82 | |
| 83 | if let Some(limit) = query.limit { |
| 84 | rows.truncate(limit); |
| 85 | } |
| 86 | |
| 87 | if !query.return_columns.is_empty() { |
| 88 | rows = predicates::project_columns(&rows, &query.return_columns); |
| 89 | } |
| 90 | |
| 91 | if query.distinct { |
| 92 | let mut seen = std::collections::HashSet::new(); |
| 93 | rows.retain(|row| { |
| 94 | let key = format!("{row:?}"); |
| 95 | seen.insert(key) |
| 96 | }); |
| 97 | } |
| 98 | |
| 99 | Ok(MatchOutcome { |
| 100 | rows, |
| 101 | truncated: state.truncated, |
| 102 | }) |
| 103 | } |
| 104 | |
| 105 | /// Serialize binding rows to MessagePack for SPSC transport. |
| 106 | /// |
no test coverage detected