pub struct StatisticsUtils;Expand description
Statistics utilities for metrics collection.
Implementations§
Source§impl StatisticsUtils
impl StatisticsUtils
Sourcepub fn compute_statistics(table: &SymbolTable) -> Result<SchemaStatistics>
pub fn compute_statistics(table: &SymbolTable) -> Result<SchemaStatistics>
Compute comprehensive statistics for a symbol table.
§Examples
use tensorlogic_adapters::{SymbolTable, DomainInfo, StatisticsUtils};
let mut table = SymbolTable::new();
table.add_domain(DomainInfo::new("Person", 100)).unwrap();
let stats = StatisticsUtils::compute_statistics(&table);
assert!(stats.is_ok());Sourcepub fn total_domain_cardinality(table: &SymbolTable) -> usize
pub fn total_domain_cardinality(table: &SymbolTable) -> usize
Get total domain cardinality.
§Examples
use tensorlogic_adapters::{SymbolTable, DomainInfo, StatisticsUtils};
let mut table = SymbolTable::new();
table.add_domain(DomainInfo::new("Person", 100)).unwrap();
table.add_domain(DomainInfo::new("Organization", 50)).unwrap();
let total = StatisticsUtils::total_domain_cardinality(&table);
assert_eq!(total, 150);Sourcepub fn average_predicate_arity(table: &SymbolTable) -> f64
pub fn average_predicate_arity(table: &SymbolTable) -> f64
Get average predicate arity.
§Examples
use tensorlogic_adapters::{SymbolTable, DomainInfo, PredicateInfo, StatisticsUtils};
let mut table = SymbolTable::new();
table.add_domain(DomainInfo::new("Person", 100)).unwrap();
table.add_predicate(PredicateInfo::new("knows", vec!["Person".to_string(), "Person".to_string()])).unwrap();
table.add_predicate(PredicateInfo::new("age", vec!["Person".to_string()])).unwrap();
let avg = StatisticsUtils::average_predicate_arity(&table);
assert_eq!(avg, 1.5);Sourcepub fn domain_usage_counts(table: &SymbolTable) -> HashMap<String, usize>
pub fn domain_usage_counts(table: &SymbolTable) -> HashMap<String, usize>
Get domain usage counts.
§Examples
use tensorlogic_adapters::{SymbolTable, DomainInfo, PredicateInfo, StatisticsUtils};
let mut table = SymbolTable::new();
table.add_domain(DomainInfo::new("Person", 100)).unwrap();
table.add_predicate(PredicateInfo::new("knows", vec!["Person".to_string(), "Person".to_string()])).unwrap();
let usage = StatisticsUtils::domain_usage_counts(&table);
assert_eq!(usage.get("Person"), Some(&2));Auto Trait Implementations§
impl Freeze for StatisticsUtils
impl RefUnwindSafe for StatisticsUtils
impl Send for StatisticsUtils
impl Sync for StatisticsUtils
impl Unpin for StatisticsUtils
impl UnwindSafe for StatisticsUtils
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