pub struct QueryOptimizer { /* private fields */ }Expand description
Query optimizer for TensorLogic
Implementations§
Source§impl QueryOptimizer
impl QueryOptimizer
Sourcepub fn plan_query(&self, goals: &[Predicate], kb: &KnowledgeBase) -> QueryPlan
pub fn plan_query(&self, goals: &[Predicate], kb: &KnowledgeBase) -> QueryPlan
Create a query plan for a conjunction of goals
Sourcepub fn get_stats(&self, predicate_name: &str) -> Option<&PredicateStats>
pub fn get_stats(&self, predicate_name: &str) -> Option<&PredicateStats>
Get predicate statistics
Sourcepub fn all_stats(&self) -> &HashMap<String, PredicateStats>
pub fn all_stats(&self) -> &HashMap<String, PredicateStats>
Get all statistics
Sourcepub fn estimate_cardinality(
&self,
predicate: &Predicate,
kb: &KnowledgeBase,
) -> f64
pub fn estimate_cardinality( &self, predicate: &Predicate, kb: &KnowledgeBase, ) -> f64
Estimate cardinality for a predicate
Sourcepub fn optimize_rule(&self, rule: &Rule, kb: &KnowledgeBase) -> Rule
pub fn optimize_rule(&self, rule: &Rule, kb: &KnowledgeBase) -> Rule
Optimize a rule by reordering its body predicates
Reorders predicates to put more selective ones first, reducing the intermediate result set size
Sourcepub fn update_statistics(&mut self, kb: &KnowledgeBase)
pub fn update_statistics(&mut self, kb: &KnowledgeBase)
Update selectivity statistics from a knowledge base
Sourcepub fn total_facts(&self) -> usize
pub fn total_facts(&self) -> usize
Get total fact count
Sourcepub fn optimize_goal(
&self,
goals: Vec<Predicate>,
kb: &KnowledgeBase,
) -> Vec<Predicate>
pub fn optimize_goal( &self, goals: Vec<Predicate>, kb: &KnowledgeBase, ) -> Vec<Predicate>
Optimize a query goal
For complex goals with multiple predicates, reorder them optimally
Sourcepub fn get_recommendations(
&self,
kb: &KnowledgeBase,
) -> Vec<OptimizationRecommendation>
pub fn get_recommendations( &self, kb: &KnowledgeBase, ) -> Vec<OptimizationRecommendation>
Get optimization recommendations for a knowledge base
Trait Implementations§
Auto Trait Implementations§
impl Freeze for QueryOptimizer
impl RefUnwindSafe for QueryOptimizer
impl Send for QueryOptimizer
impl Sync for QueryOptimizer
impl Unpin for QueryOptimizer
impl UnwindSafe for QueryOptimizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more