pub struct ConfigFileStatisticsProvider { /* private fields */ }Expand description
A StatisticsProvider that loads a catalog from a JSON or YAML file.
The file format is inferred from the extension: .yaml/.yml are
parsed as YAML and anything else is parsed as JSON. The file is read
eagerly when the provider is constructed so later lookups are
infallible reads of the in-memory catalog.
§Examples
use vlorql_core::statistics::{ConfigFileStatisticsProvider, StatisticsProvider};
let provider = ConfigFileStatisticsProvider::load("stats.yaml").unwrap();
let catalog = provider.get_catalog_stats().await.unwrap();
println!("{} tables", catalog.tables.len());Implementations§
Source§impl ConfigFileStatisticsProvider
impl ConfigFileStatisticsProvider
Sourcepub fn load(path: impl AsRef<Path>) -> Result<Self, VlorQLError>
pub fn load(path: impl AsRef<Path>) -> Result<Self, VlorQLError>
Reads and parses a statistics file, inferring the format from the
file extension (.yaml/.yml for YAML, otherwise JSON).
Returns a ConfigErrorKind::ConfigFileError if the file cannot
be read or its contents cannot be parsed.
Sourcepub fn from_str(
path: impl AsRef<Path>,
contents: &str,
) -> Result<Self, VlorQLError>
pub fn from_str( path: impl AsRef<Path>, contents: &str, ) -> Result<Self, VlorQLError>
Parses a catalog from an in-memory string, using path only to
choose the format and to build error messages.
This is the I/O-free core of Self::load and is handy in tests
that do not want to touch the filesystem.
Trait Implementations§
Source§impl Clone for ConfigFileStatisticsProvider
impl Clone for ConfigFileStatisticsProvider
Source§fn clone(&self) -> ConfigFileStatisticsProvider
fn clone(&self) -> ConfigFileStatisticsProvider
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 ConfigFileStatisticsProvider
impl Debug for ConfigFileStatisticsProvider
Source§impl StatisticsProvider for ConfigFileStatisticsProvider
impl StatisticsProvider for ConfigFileStatisticsProvider
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 ConfigFileStatisticsProvider
impl RefUnwindSafe for ConfigFileStatisticsProvider
impl Send for ConfigFileStatisticsProvider
impl Sync for ConfigFileStatisticsProvider
impl Unpin for ConfigFileStatisticsProvider
impl UnsafeUnpin for ConfigFileStatisticsProvider
impl UnwindSafe for ConfigFileStatisticsProvider
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