pub struct DummyStatisticsProvider { /* private fields */ }Expand description
A StatisticsProvider backed by a fixed in-memory catalog.
Useful in tests and for supplying hand-authored estimates. Construct
it with a prepared StatisticsCatalog via Self::new, or with
an empty catalog via Default.
§Examples
use vlorql_core::statistics::{
DummyStatisticsProvider, StatisticsCatalog, StatisticsProvider, TableStatistics,
};
let mut catalog = StatisticsCatalog::default();
catalog.tables.insert(
"users".to_owned(),
TableStatistics {
row_count: 1_000,
..TableStatistics::default()
},
);
let provider = DummyStatisticsProvider::new(catalog);
let stats = provider.get_table_stats("users").await.unwrap().unwrap();
assert_eq!(stats.row_count, 1_000);
assert!(provider.get_table_stats("missing").await.unwrap().is_none());Implementations§
Source§impl DummyStatisticsProvider
impl DummyStatisticsProvider
Sourcepub fn new(catalog: StatisticsCatalog) -> Self
pub fn new(catalog: StatisticsCatalog) -> Self
Creates a provider that serves the given catalog.
Trait Implementations§
Source§impl Clone for DummyStatisticsProvider
impl Clone for DummyStatisticsProvider
Source§fn clone(&self) -> DummyStatisticsProvider
fn clone(&self) -> DummyStatisticsProvider
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DummyStatisticsProvider
impl Debug for DummyStatisticsProvider
Source§impl Default for DummyStatisticsProvider
impl Default for DummyStatisticsProvider
Source§fn default() -> DummyStatisticsProvider
fn default() -> DummyStatisticsProvider
Returns the “default value” for a type. Read more
Source§impl StatisticsProvider for DummyStatisticsProvider
impl StatisticsProvider for DummyStatisticsProvider
Source§fn get_table_stats<'life0, 'life1, 'async_trait>(
&'life0 self,
table_name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TableStatistics>, VlorQLError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_table_stats<'life0, 'life1, 'async_trait>(
&'life0 self,
table_name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TableStatistics>, VlorQLError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns statistics for
table_name, or None if the provider
has none for that table.Source§fn get_column_stats<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table_name: &'life1 str,
column_name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ColumnStatistics>, VlorQLError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_column_stats<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table_name: &'life1 str,
column_name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ColumnStatistics>, VlorQLError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Returns statistics for
table_name.column_name, or None if the
provider has none for that column.Source§fn get_catalog_stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<StatisticsCatalog, VlorQLError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_catalog_stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<StatisticsCatalog, VlorQLError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns the full statistics catalog known to the provider.
Auto Trait Implementations§
impl Freeze for DummyStatisticsProvider
impl RefUnwindSafe for DummyStatisticsProvider
impl Send for DummyStatisticsProvider
impl Sync for DummyStatisticsProvider
impl Unpin for DummyStatisticsProvider
impl UnsafeUnpin for DummyStatisticsProvider
impl UnwindSafe for DummyStatisticsProvider
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request