Execute a MATCH query on a CSR index and edge store. Applies join order optimization before execution: triples within each PatternChain are reordered by selectivity (lowest edge count first, bound variables preferred). `frontier_bitmap`: when `Some`, only nodes whose surrogate is present in the bitmap are eligible as pattern anchors. Bound variables (already resolved from a prior binding row) by
(
query: &MatchQuery,
csr: &CsrIndex,
edge_store: &EdgeStore,
frontier_bitmap: Option<&nodedb_types::SurrogateBitmap>,
)
| 46 | /// from a prior binding row) bypass the bitmap check — only free-variable |
| 47 | /// anchor enumeration is restricted. |
| 48 | pub fn execute( |
| 49 | query: &MatchQuery, |
| 50 | csr: &CsrIndex, |
| 51 | edge_store: &EdgeStore, |
| 52 | frontier_bitmap: Option<&nodedb_types::SurrogateBitmap>, |
| 53 | ) -> Result<MatchOutcome, crate::Error> { |
| 54 | // Optimize query before execution (reorder triples by selectivity). |
| 55 | let mut optimized = query.clone(); |
| 56 | super::optimizer::optimize(&mut optimized, csr); |
| 57 | execute_query(&optimized, csr, edge_store, frontier_bitmap) |
| 58 | } |
| 59 | |
| 60 | /// Execute a pre-optimized MATCH query (internal, skip optimizer). |
| 61 | fn execute_query( |