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

Method plan_query

graphlite/src/plan/optimizer.rs:165–196  ·  view source on GitHub ↗

Plan a query from AST document

(&mut self, document: &Document)

Source from the content-addressed store, hash-verified

163
164 /// Plan a query from AST document
165 pub fn plan_query(&mut self, document: &Document) -> Result<PhysicalPlan, PlanningError> {
166 // Extract query from document
167 let query = match &document.statement {
168 crate::ast::Statement::Query(q) => q,
169 _ => {
170 return Err(PlanningError::InvalidQuery(
171 "Document does not contain a query statement".to_string(),
172 ))
173 }
174 };
175
176 // Generate logical plan
177 let logical_plan = self.create_logical_plan(query)?;
178
179 // Optimize logical plan
180 let mut optimized_logical = self.optimize_logical_plan(logical_plan)?;
181
182 // Apply index-aware transformations (text_search, etc.)
183 // Create a temporary IndexAwareOptimizer with empty indexes
184 // This allows text_search transformation to work even without registered indexes
185 let empty_indexes: Vec<IndexInfo> = vec![];
186 let mut index_optimizer = IndexAwareOptimizer::new(&empty_indexes, &self.cost_model);
187 optimized_logical = index_optimizer.apply_index_rules(optimized_logical)?;
188
189 // Convert to physical plan
190 let physical_plan = self.create_physical_plan(optimized_logical)?;
191
192 // Optimize physical plan
193 let optimized_physical = self.optimize_physical_plan(physical_plan)?;
194
195 Ok(optimized_physical)
196 }
197
198 /// Plan a query with detailed tracing for EXPLAIN
199 pub fn plan_query_with_trace(

Calls 5

optimize_logical_planMethod · 0.80
apply_index_rulesMethod · 0.80
create_physical_planMethod · 0.80
create_logical_planMethod · 0.45

Tested by

no test coverage detected